@simplysm/sd-cli 10.0.66 → 11.0.4
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/build-cluster.js +16 -15
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +20 -0
- package/dist/build-tools/SdNgBundler.js +312 -0
- package/dist/build-tools/SdNgBundler.js.map +1 -0
- package/dist/build-tools/SdTsBundler.d.ts +15 -0
- package/dist/build-tools/SdTsBundler.js +96 -0
- package/dist/build-tools/SdTsBundler.js.map +1 -0
- package/dist/build-tools/SdTsCompiler.d.ts +28 -0
- package/dist/build-tools/SdTsCompiler.js +212 -0
- package/dist/build-tools/SdTsCompiler.js.map +1 -0
- package/dist/builders/SdCliClientBuilder.d.ts +5 -7
- package/dist/builders/SdCliClientBuilder.js +75 -267
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +4 -3
- package/dist/builders/SdCliServerBuilder.js +82 -218
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +3 -4
- package/dist/builders/SdCliTsLibBuilder.js +37 -87
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +11 -5
- package/dist/entry/SdCliProject.js +22 -18
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +3 -11
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +0 -19
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js +3 -0
- package/dist/server-worker.js.map +1 -1
- package/package.json +17 -19
- package/src/build-cluster.ts +16 -15
- package/src/build-tools/SdNgBundler.ts +381 -0
- package/src/build-tools/SdTsBundler.ts +106 -0
- package/src/build-tools/SdTsCompiler.ts +304 -0
- package/src/builders/SdCliClientBuilder.ts +93 -312
- package/src/builders/SdCliServerBuilder.ts +99 -242
- package/src/builders/SdCliTsLibBuilder.ts +41 -111
- package/src/commons.ts +11 -5
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliLocalUpdate.ts +3 -3
- package/src/entry/SdCliProject.ts +33 -26
- package/src/index.ts +3 -11
- package/src/sd-cli.ts +0 -23
- package/src/server-worker.ts +3 -0
- package/dist/build-tools/SdTsIncrementalBuilder.d.ts +0 -29
- package/dist/build-tools/SdTsIncrementalBuilder.js +0 -75
- package/dist/build-tools/SdTsIncrementalBuilder.js.map +0 -1
- package/dist/entry/SdCliPwaAssets.d.ts +0 -6
- package/dist/entry/SdCliPwaAssets.js +0 -39
- package/dist/entry/SdCliPwaAssets.js.map +0 -1
- package/dist/utils/SdCliViteElectronMainPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteElectronMainPlugin.js +0 -96
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +0 -1
- package/dist/utils/SdCliViteExternalPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteExternalPlugin.js +0 -85
- package/dist/utils/SdCliViteExternalPlugin.js.map +0 -1
- package/dist/utils/SdCliViteLazyImportPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteLazyImportPlugin.js +0 -23
- package/dist/utils/SdCliViteLazyImportPlugin.js.map +0 -1
- package/dist/utils/SdCliViteLoggerPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteLoggerPlugin.js +0 -24
- package/dist/utils/SdCliViteLoggerPlugin.js.map +0 -1
- package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteNodeGlobalPlugin.js +0 -29
- package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +0 -1
- package/dist/utils/SdCliViteReactSwcPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteReactSwcPlugin.js +0 -139
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +0 -1
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.d.ts +0 -2
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js +0 -36
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js.map +0 -1
- package/dist/utils/getElectronReactExternals.d.ts +0 -1
- package/dist/utils/getElectronReactExternals.js +0 -17
- package/dist/utils/getElectronReactExternals.js.map +0 -1
- package/dist/utils/sdCliTsDefineTransformer.d.ts +0 -4
- package/dist/utils/sdCliTsDefineTransformer.js +0 -26
- package/dist/utils/sdCliTsDefineTransformer.js.map +0 -1
- package/src/build-tools/SdTsIncrementalBuilder.ts +0 -125
- package/src/entry/SdCliPwaAssets.ts +0 -50
- package/src/utils/SdCliViteElectronMainPlugin.ts +0 -102
- package/src/utils/SdCliViteExternalPlugin.ts +0 -98
- package/src/utils/SdCliViteLazyImportPlugin.ts +0 -26
- package/src/utils/SdCliViteLoggerPlugin.ts +0 -29
- package/src/utils/SdCliViteNodeGlobalPlugin.ts +0 -31
- package/src/utils/SdCliViteReactSwcPlugin.ts +0 -153
- package/src/utils/SdCliViteServeOptimizeExcludePlugin.ts +0 -42
- package/src/utils/getElectronReactExternals.ts +0 -19
- package/src/utils/sdCliTsDefineTransformer.ts +0 -33
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
import {EventEmitter} from "events";
|
|
2
|
-
import {FsUtil, Logger, SdFsWatcher
|
|
3
|
-
import {
|
|
4
|
-
import {FunctionQueue
|
|
5
|
-
import * as vite from "vite";
|
|
6
|
-
import {defineConfig, InlineConfig} from "vite";
|
|
7
|
-
import vitePluginPaths from "vite-tsconfig-paths";
|
|
2
|
+
import {FsUtil, Logger, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
3
|
+
import {ISdCliBuilderResult, ISdCliClientPackageConfig, ISdCliConfig} from "../commons";
|
|
4
|
+
import {FunctionQueue} from "@simplysm/sd-core-common";
|
|
8
5
|
import path from "path";
|
|
9
|
-
import {
|
|
6
|
+
import {SdTsCompiler} from "../build-tools/SdTsCompiler";
|
|
7
|
+
import {SdNgBundler} from "../build-tools/SdNgBundler";
|
|
10
8
|
import {SdLinter} from "../build-tools/SdLinter";
|
|
11
|
-
import {VitePWA} from 'vite-plugin-pwa';
|
|
12
|
-
import {SdCliViteNodeGlobalPlugin} from "../utils/SdCliViteNodeGlobalPlugin";
|
|
13
|
-
import {SdCliViteLoggerPlugin} from "../utils/SdCliViteLoggerPlugin";
|
|
14
|
-
import {SdCliViteReactSwcPlugin} from "../utils/SdCliViteReactSwcPlugin";
|
|
15
|
-
import {SdCliViteExternalPlugin} from "../utils/SdCliViteExternalPlugin";
|
|
16
|
-
import {SdCliViteElectronMainPlugin} from "../utils/SdCliViteElectronMainPlugin";
|
|
17
|
-
import electronBuilder from "electron-builder";
|
|
18
|
-
import {SdCliViteServeOptimizeExcludePlugin} from "../utils/SdCliViteServeOptimizeExcludePlugin";
|
|
19
|
-
import {SdCliViteLazyImportPlugin} from "../utils/SdCliViteLazyImportPlugin";
|
|
20
9
|
|
|
21
10
|
export class SdCliClientBuilder extends EventEmitter {
|
|
22
11
|
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliClientBuilder"]);
|
|
12
|
+
private readonly _pkgConf: ISdCliClientPackageConfig;
|
|
23
13
|
|
|
24
|
-
public constructor(private readonly
|
|
25
|
-
private readonly
|
|
26
|
-
private readonly _builderKey: "web" | "electron",
|
|
27
|
-
private readonly _withLint: boolean) {
|
|
14
|
+
public constructor(private readonly _projConf: ISdCliConfig,
|
|
15
|
+
private readonly _pkgPath: string) {
|
|
28
16
|
super();
|
|
17
|
+
this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdCliClientPackageConfig;
|
|
29
18
|
}
|
|
30
19
|
|
|
31
20
|
public override on(event: "change", listener: () => void): this;
|
|
@@ -35,320 +24,112 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
35
24
|
return this;
|
|
36
25
|
}
|
|
37
26
|
|
|
38
|
-
public async
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
28
|
+
this._debug("dist 초기화...");
|
|
29
|
+
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
30
|
+
|
|
31
|
+
this._debug("GEN .config...");
|
|
32
|
+
const confDistPath = this._pkgConf.server !== undefined
|
|
33
|
+
? path.resolve(this._pkgPath, "../../packages", this._pkgConf.server, "dist/www", path.basename(this._pkgPath), ".config.json")
|
|
34
|
+
: path.resolve(this._pkgPath, "dist");
|
|
35
|
+
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
36
|
+
|
|
37
|
+
this._debug(`BUILD 준비...`);
|
|
38
|
+
const builderTypes = (Object.keys(this._pkgConf.builder ?? {web: {}}) as ("web")[]);
|
|
39
|
+
const builders = builderTypes.map((builderType) => new SdNgBundler({
|
|
40
|
+
dev: false,
|
|
41
|
+
builderType: builderType,
|
|
42
|
+
pkgPath: this._pkgPath
|
|
50
43
|
}));
|
|
51
|
-
await viteServer.listen(viteServerPort);
|
|
52
|
-
|
|
53
|
-
this._debug("CHECK...");
|
|
54
|
-
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: false}));
|
|
55
|
-
const checkResult = await sdTsProgram.buildAsync();
|
|
56
|
-
|
|
57
|
-
this._debug("LINT...");
|
|
58
|
-
const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(checkResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
59
|
-
|
|
60
|
-
this._debug("WATCH...");
|
|
61
|
-
const fnQ = new FunctionQueue();
|
|
62
|
-
SdFsWatcher
|
|
63
|
-
.watch([
|
|
64
|
-
...sdTsProgram.builderProgram!.getSourceFiles().map((item) => item.fileName),
|
|
65
|
-
path.resolve(this._pkgPath, "src/**/*.{ts,tsx}")
|
|
66
|
-
])
|
|
67
|
-
.onChange({
|
|
68
|
-
delay: 100
|
|
69
|
-
}, () => {
|
|
70
|
-
fnQ.runLast(async () => {
|
|
71
|
-
this.emit("change");
|
|
72
44
|
|
|
73
|
-
|
|
74
|
-
|
|
45
|
+
const checker = new SdTsCompiler({
|
|
46
|
+
pkgPath: this._pkgPath,
|
|
47
|
+
emit: false,
|
|
48
|
+
emitDts: false,
|
|
49
|
+
globalStyle: false
|
|
50
|
+
});
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
this._debug(`BUILD...`);
|
|
53
|
+
const buildResults = (
|
|
54
|
+
await Promise.all(builders.map((builder) => builder.bundleAsync()))
|
|
55
|
+
).mapMany();
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
port: viteServerPort,
|
|
82
|
-
affectedFilePaths: watchCheckResult.affectedFilePaths,
|
|
83
|
-
buildResults: [...watchCheckResult.results, ...watchLintResults]
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
57
|
+
this._debug("CHECK...");
|
|
58
|
+
const checkResult = await checker.buildAsync();
|
|
87
59
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const confDistPath = path.resolve(this._pkgPath, "../../packages", this._pkgConf.server, "dist/www", path.basename(this._pkgPath), ".config.json");
|
|
91
|
-
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
92
|
-
}
|
|
60
|
+
this._debug(`LINT...`);
|
|
61
|
+
const lintResults = await SdLinter.lintAsync(checkResult.affectedFilePaths, checker.program);
|
|
93
62
|
|
|
94
63
|
this._debug(`빌드 완료`);
|
|
95
|
-
|
|
96
|
-
port: viteServerPort,
|
|
64
|
+
return {
|
|
97
65
|
affectedFilePaths: checkResult.affectedFilePaths,
|
|
98
|
-
buildResults: [...checkResult.results, ...lintResults]
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return viteServerPort;
|
|
66
|
+
buildResults: [...buildResults, ...checkResult.results, ...lintResults]
|
|
67
|
+
};
|
|
102
68
|
}
|
|
103
69
|
|
|
104
|
-
public async
|
|
70
|
+
public async watchAsync(): Promise<void> {
|
|
105
71
|
this._debug("dist 초기화...");
|
|
106
|
-
|
|
107
|
-
const distPath = path.resolve(this._pkgPath, "dist", ...this._builderKey !== "web" ? [this._builderKey] : []);
|
|
108
|
-
await FsUtil.removeAsync(cachePath);
|
|
109
|
-
await FsUtil.removeAsync(distPath);
|
|
110
|
-
|
|
111
|
-
this._debug("BUILD...");
|
|
112
|
-
const buildResults: ISdCliPackageBuildResult[] = [];
|
|
113
|
-
try {
|
|
114
|
-
await vite.build(this._getViteConfig({
|
|
115
|
-
dev: false,
|
|
116
|
-
pkgConf: this._pkgConf,
|
|
117
|
-
cachePath: cachePath,
|
|
118
|
-
distPath: distPath,
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
if ("errors" in err && err.errors instanceof Array) {
|
|
123
|
-
buildResults.push(...err.errors.map((item: any) => ({
|
|
124
|
-
filePath: item.location.file,
|
|
125
|
-
line: item.location.line,
|
|
126
|
-
char: item.location.column,
|
|
127
|
-
code: undefined,
|
|
128
|
-
severity: "error" as const,
|
|
129
|
-
message: item.text
|
|
130
|
-
})));
|
|
131
|
-
}
|
|
132
|
-
if ("warnings" in err && err.warnings instanceof Array) {
|
|
133
|
-
buildResults.push(...err.warnings.map((item: any) => ({
|
|
134
|
-
filePath: item.location.file,
|
|
135
|
-
line: item.location.line,
|
|
136
|
-
char: item.location.column,
|
|
137
|
-
code: undefined,
|
|
138
|
-
severity: "warning" as const,
|
|
139
|
-
message: item.text
|
|
140
|
-
})));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this._debug("CHECK...");
|
|
145
|
-
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: false}));
|
|
146
|
-
const checkResult = await sdTsProgram.buildAsync();
|
|
147
|
-
|
|
148
|
-
this._debug("LINT...");
|
|
149
|
-
const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(checkResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
150
|
-
|
|
151
|
-
if (this._pkgConf.server !== undefined) {
|
|
152
|
-
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
153
|
-
this._debug("GEN .config...");
|
|
154
|
-
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
155
|
-
}
|
|
72
|
+
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
156
73
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
74
|
+
this._debug("GEN .config...");
|
|
75
|
+
const confDistPath = this._pkgConf.server !== undefined
|
|
76
|
+
? path.resolve(this._pkgPath, "../../packages", this._pkgConf.server, "dist/www", path.basename(this._pkgPath), ".config.json")
|
|
77
|
+
: path.resolve(this._pkgPath, "dist");
|
|
78
|
+
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
161
79
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
main: "electron-main.js",
|
|
170
|
-
...this._pkgConf.builder!.electron!.postInstallScript !== undefined ? {
|
|
171
|
-
scripts: {
|
|
172
|
-
"postinstall": this._pkgConf.builder!.electron!.postInstallScript
|
|
173
|
-
},
|
|
174
|
-
} : {},
|
|
175
|
-
dependencies: externalPkgNames.toObject((item) => item, (item) => pkgNpmConfig.dependencies![item] ?? "*")
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
this._debug("npm install...");
|
|
179
|
-
await SdProcess.spawnAsync(`npm install`, {cwd: electronSrcPath}, true);
|
|
80
|
+
this._debug(`BUILD 준비...`);
|
|
81
|
+
const builderTypes = (Object.keys(this._pkgConf.builder ?? {web: {}}) as ("web")[]);
|
|
82
|
+
const builders = builderTypes.map((builderType) => new SdNgBundler({
|
|
83
|
+
dev: true,
|
|
84
|
+
builderType: builderType,
|
|
85
|
+
pkgPath: this._pkgPath
|
|
86
|
+
}));
|
|
180
87
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
88
|
+
const checker = new SdTsCompiler({
|
|
89
|
+
pkgPath: this._pkgPath,
|
|
90
|
+
emit: false,
|
|
91
|
+
emitDts: false,
|
|
92
|
+
globalStyle: false
|
|
93
|
+
});
|
|
187
94
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
},
|
|
202
|
-
...this._pkgConf.builder!.electron!.installerIcon !== undefined ? {
|
|
203
|
-
icon: path.resolve(this._pkgPath, "src", this._pkgConf.builder!.electron!.installerIcon)
|
|
204
|
-
} : {},
|
|
205
|
-
removePackageScripts: false
|
|
95
|
+
this._debug("WATCH...");
|
|
96
|
+
const fnQ = new FunctionQueue();
|
|
97
|
+
const watcher = SdFsWatcher
|
|
98
|
+
.watch([
|
|
99
|
+
path.resolve(this._pkgPath, "src/**/*.*")
|
|
100
|
+
], {
|
|
101
|
+
ignoreInitial: false
|
|
102
|
+
})
|
|
103
|
+
.onChange({
|
|
104
|
+
delay: 100
|
|
105
|
+
}, (changeInfos) => {
|
|
106
|
+
for (const builder of builders) {
|
|
107
|
+
builder.removeCache(changeInfos.map((item) => item.path));
|
|
206
108
|
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
await FsUtil.copyAsync(
|
|
210
|
-
path.resolve(electronDistPath, `${pkgNpmConfig.description} Setup ${pkgNpmConfig.version}.exe`),
|
|
211
|
-
path.resolve(distPath, `electron/${pkgNpmConfig.description}-latest.exe`)
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
await FsUtil.copyAsync(
|
|
215
|
-
path.resolve(electronDistPath, `${pkgNpmConfig.description} Setup ${pkgNpmConfig.version}.exe`),
|
|
216
|
-
path.resolve(distPath, `electron/updates/${pkgNpmConfig.version}.exe`)
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this._debug(`빌드 완료`);
|
|
222
|
-
return {
|
|
223
|
-
affectedFilePaths: checkResult.affectedFilePaths,
|
|
224
|
-
buildResults: [...buildResults, ...checkResult.results, ...lintResults]
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
109
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
cachePath: string,
|
|
231
|
-
distPath?: string,
|
|
232
|
-
port?: number,
|
|
233
|
-
pkgConf: ISdCliClientPackageConfig
|
|
234
|
-
}): InlineConfig {
|
|
235
|
-
const pkgNpmConf: INpmConfig = FsUtil.readJson(path.resolve(this._pkgPath, "package.json"));
|
|
110
|
+
fnQ.runLast(async () => {
|
|
111
|
+
this.emit("change");
|
|
236
112
|
|
|
237
|
-
|
|
113
|
+
this._debug(`BUILD...`);
|
|
114
|
+
const buildResults = (
|
|
115
|
+
await Promise.all(builders.map((builder) => builder.bundleAsync()))
|
|
116
|
+
).mapMany();
|
|
238
117
|
|
|
239
|
-
|
|
118
|
+
this._debug("CHECK...");
|
|
119
|
+
const checkResult = await checker.buildAsync();
|
|
240
120
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
"import.meta.env.SD_SERVER_URL": JSON.stringify(`http://${serverHost}:${opt.port}` + basePath)
|
|
244
|
-
} : {},
|
|
245
|
-
"import.meta.env.SD_VERSION": JSON.stringify(pkgNpmConf.version),
|
|
246
|
-
...this._pkgConf.env
|
|
247
|
-
? Object.keys(this._pkgConf.env)
|
|
248
|
-
.toObject(
|
|
249
|
-
(key) => "import.meta.env." + key,
|
|
250
|
-
(key) => JSON.stringify(this._pkgConf.env![key])
|
|
251
|
-
)
|
|
252
|
-
: {},
|
|
253
|
-
...this._pkgConf.builder?.[this._builderKey]?.env
|
|
254
|
-
? Object.keys(this._pkgConf.builder[this._builderKey]!.env!)
|
|
255
|
-
.toObject(
|
|
256
|
-
(key) => "import.meta.env." + key,
|
|
257
|
-
(key) => JSON.stringify(this._pkgConf.builder![this._builderKey]!.env![key])
|
|
258
|
-
)
|
|
259
|
-
: {}
|
|
260
|
-
};
|
|
121
|
+
this._debug(`LINT...`);
|
|
122
|
+
const lintResults = await SdLinter.lintAsync(checkResult.affectedFilePaths, checker.program);
|
|
261
123
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
assetsInclude: [
|
|
268
|
-
"**/*.xlsx",
|
|
269
|
-
"**/*.xls",
|
|
270
|
-
"**/*.docx",
|
|
271
|
-
"**/*.doc",
|
|
272
|
-
"**/*.pptx",
|
|
273
|
-
"**/*.ppt",
|
|
274
|
-
"**/*.woff",
|
|
275
|
-
"**/*.woff2",
|
|
276
|
-
"**/*.ttf",
|
|
277
|
-
"**/*.eot",
|
|
278
|
-
"**/*.otf",
|
|
279
|
-
"**/*.csv",
|
|
280
|
-
"**/*.zip",
|
|
281
|
-
"**/*.pfx",
|
|
282
|
-
"**/*.pkl"
|
|
283
|
-
],
|
|
284
|
-
define: define,
|
|
285
|
-
...opt.dev ? {
|
|
286
|
-
server: {
|
|
287
|
-
host: serverHost,
|
|
288
|
-
port: opt.port,
|
|
289
|
-
hmr: {
|
|
290
|
-
host: serverHost,
|
|
291
|
-
port: opt.port
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
} : {},
|
|
295
|
-
optimizeDeps: {
|
|
296
|
-
force: true
|
|
297
|
-
},
|
|
298
|
-
...!opt.dev ? {
|
|
299
|
-
build: {
|
|
300
|
-
outDir: this._builderKey === "electron" ? path.resolve(opt.cachePath, "src") : opt.distPath,
|
|
301
|
-
rollupOptions: {
|
|
302
|
-
output: {
|
|
303
|
-
entryFileNames: `assets/[name].js`,
|
|
304
|
-
chunkFileNames: `assets/[name].js`,
|
|
305
|
-
assetFileNames: `assets/[name].[ext]`
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
} : {},
|
|
310
|
-
plugins: [
|
|
311
|
-
SdCliViteReactSwcPlugin(),
|
|
312
|
-
SdCliViteLoggerPlugin({
|
|
313
|
-
logger: this._logger,
|
|
314
|
-
name: path.basename(this._pkgPath)
|
|
315
|
-
}),
|
|
316
|
-
vitePluginPaths(),
|
|
317
|
-
...opt.dev ? [
|
|
318
|
-
SdCliViteLazyImportPlugin()
|
|
319
|
-
] : [],
|
|
320
|
-
...opt.dev ? [
|
|
321
|
-
SdCliViteServeOptimizeExcludePlugin([
|
|
322
|
-
"@simplysm/*"
|
|
323
|
-
])
|
|
324
|
-
] : [],
|
|
325
|
-
...!opt.dev && this._builderKey === "web" ? [
|
|
326
|
-
VitePWA({
|
|
327
|
-
mode: "production",
|
|
328
|
-
base: `/${path.basename(this._pkgPath)}/`,
|
|
329
|
-
includeAssets: ["favicon.ico", "assets/icons/apple-touch-icon-180x180.png", "assets/icons/maskable-icon-512x512.png"],
|
|
124
|
+
this._debug(`빌드 완료`);
|
|
125
|
+
this.emit("complete", {
|
|
126
|
+
affectedFilePaths: checkResult.affectedFilePaths,
|
|
127
|
+
buildResults: [...buildResults, ...checkResult.results, ...lintResults]
|
|
128
|
+
});
|
|
330
129
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
] : [],
|
|
335
|
-
...this._builderKey === "web" ? [
|
|
336
|
-
SdCliViteNodeGlobalPlugin()
|
|
337
|
-
] : [],
|
|
338
|
-
...this._builderKey === "electron" ? [
|
|
339
|
-
SdCliViteElectronMainPlugin({
|
|
340
|
-
entry: path.resolve(this._pkgPath, "src/electron-main.ts"),
|
|
341
|
-
distPath: path.resolve(opt.cachePath, "src"),
|
|
342
|
-
cachePath: path.resolve(opt.cachePath, "electron-main")
|
|
343
|
-
}),
|
|
344
|
-
SdCliViteExternalPlugin({
|
|
345
|
-
target: "browser",
|
|
346
|
-
cachePath: path.resolve(opt.cachePath, "external"),
|
|
347
|
-
includes: opt.pkgConf.builder?.electron?.reinstallDependencies
|
|
348
|
-
})
|
|
349
|
-
] : [],
|
|
350
|
-
],
|
|
351
|
-
});
|
|
130
|
+
watcher.add(checker.program.getSourceFiles().map((item) => item.fileName));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
352
133
|
}
|
|
353
134
|
|
|
354
135
|
private _debug(msg: string): void {
|