@simplysm/sd-cli 12.5.15 → 12.5.16
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-tools/SdCliIndexFileGenerator.js +2 -2
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
- package/dist/build-tools/SdLinter.d.ts +1 -1
- package/dist/build-tools/SdLinter.js +27 -23
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +7 -1
- package/dist/build-tools/SdTsCompiler.js +32 -20
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/build-tools/SdTsLibBundler.js +7 -1
- package/dist/build-tools/SdTsLibBundler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +1 -1
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliJsLibLinter.js +3 -3
- package/dist/builders/SdCliJsLibLinter.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.js +42 -43
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +4 -2
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.js +6 -1
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdServerPlugin.js +20 -5
- package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
- package/dist/entry/SdCliElectron.js +5 -5
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliProject.js +4 -2
- package/dist/entry/SdCliProject.js.map +1 -1
- package/eslint.config.js +1 -0
- package/lib/postinstall.js +1 -1
- package/package.json +6 -6
- package/src/build-tools/SdCliIndexFileGenerator.ts +2 -2
- package/src/build-tools/SdLinter.ts +30 -29
- package/src/build-tools/SdTsCompiler.ts +34 -15
- package/src/build-tools/SdTsLibBundler.ts +7 -1
- package/src/builders/SdCliClientBuilder.ts +2 -1
- package/src/builders/SdCliJsLibLinter.ts +3 -3
- package/src/builders/SdCliServerBuilder.ts +110 -88
- package/src/builders/SdCliTsLibBuilder.ts +3 -3
- package/src/bundle-plugins/sdNgPlugin.ts +6 -1
- package/src/bundle-plugins/sdServerPlugin.ts +29 -13
- package/src/entry/SdCliElectron.ts +5 -5
- package/src/entry/SdCliProject.ts +4 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {EventEmitter} from "events";
|
|
2
|
-
import {FsUtil, Logger, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
3
3
|
import {
|
|
4
4
|
INpmConfig,
|
|
5
5
|
ISdCliBuilderResult,
|
|
6
6
|
ISdCliConfig,
|
|
7
7
|
ISdCliPackageBuildResult,
|
|
8
8
|
ISdCliServerPackageConfig,
|
|
9
|
-
ITsConfig
|
|
9
|
+
ITsConfig,
|
|
10
10
|
} from "../commons";
|
|
11
11
|
import path from "path";
|
|
12
|
-
import {SdLinter} from "../build-tools/SdLinter";
|
|
13
|
-
import {FunctionQueue, ObjectUtil, StringUtil} from "@simplysm/sd-core-common";
|
|
14
|
-
import {SdServerBundler} from "../build-tools/SdServerBundler";
|
|
12
|
+
import { SdLinter } from "../build-tools/SdLinter";
|
|
13
|
+
import { FunctionQueue, ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
|
|
14
|
+
import { SdServerBundler } from "../build-tools/SdServerBundler";
|
|
15
15
|
|
|
16
16
|
export class SdCliServerBuilder extends EventEmitter {
|
|
17
17
|
#logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
|
|
@@ -19,8 +19,10 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
19
19
|
#builder?: SdServerBundler;
|
|
20
20
|
#extModules?: { name: string; exists: boolean }[];
|
|
21
21
|
|
|
22
|
-
public constructor(
|
|
23
|
-
|
|
22
|
+
public constructor(
|
|
23
|
+
private readonly _projConf: ISdCliConfig,
|
|
24
|
+
private readonly _pkgPath: string,
|
|
25
|
+
) {
|
|
24
26
|
super();
|
|
25
27
|
this.#pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdCliServerPackageConfig;
|
|
26
28
|
}
|
|
@@ -42,37 +44,35 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
42
44
|
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
43
45
|
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this.#pkgConf.configs ?? {}, undefined, 2));
|
|
44
46
|
|
|
45
|
-
const result = await this._runAsync({dev: true});
|
|
47
|
+
const result = await this._runAsync({ dev: true });
|
|
46
48
|
this.emit("complete", {
|
|
47
49
|
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
48
|
-
buildResults: result.buildResults
|
|
50
|
+
buildResults: result.buildResults,
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
this._debug("WATCH...");
|
|
52
54
|
let changeFiles: string[] = [];
|
|
53
55
|
const fnQ = new FunctionQueue();
|
|
54
|
-
const watcher = SdFsWatcher
|
|
55
|
-
.
|
|
56
|
-
.onChange({delay: 100}, (changeInfos) => {
|
|
57
|
-
changeFiles.push(...changeInfos.map((item) => item.path));
|
|
56
|
+
const watcher = SdFsWatcher.watch(Array.from(result.watchFileSet)).onChange({ delay: 100 }, (changeInfos) => {
|
|
57
|
+
changeFiles.push(...changeInfos.map((item) => item.path));
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
fnQ.runLast(async () => {
|
|
60
|
+
const currChangeFiles = [...changeFiles];
|
|
61
|
+
changeFiles = [];
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
this.emit("change");
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
this.#builder!.markForChanges(currChangeFiles);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
watcher.add(watchResult.watchFileSet);
|
|
67
|
+
const watchResult = await this._runAsync({ dev: true });
|
|
68
|
+
this.emit("complete", {
|
|
69
|
+
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
70
|
+
buildResults: watchResult.buildResults,
|
|
74
71
|
});
|
|
72
|
+
|
|
73
|
+
watcher.add(watchResult.watchFileSet);
|
|
75
74
|
});
|
|
75
|
+
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
@@ -84,7 +84,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
84
84
|
|
|
85
85
|
this._debug("GEN .config.json...");
|
|
86
86
|
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
87
|
-
await FsUtil.writeJsonAsync(confDistPath, this.#pkgConf.configs ?? {}, {space: 2});
|
|
87
|
+
await FsUtil.writeJsonAsync(confDistPath, this.#pkgConf.configs ?? {}, { space: 2 });
|
|
88
88
|
|
|
89
89
|
this._debug("GEN package.json...");
|
|
90
90
|
{
|
|
@@ -100,14 +100,10 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
100
100
|
delete distNpmConfig.peerDependencies;
|
|
101
101
|
|
|
102
102
|
if (this.#pkgConf.pm2 && !this.#pkgConf.pm2.noStartScript) {
|
|
103
|
-
distNpmConfig.scripts = {
|
|
103
|
+
distNpmConfig.scripts = { start: "pm2 start pm2.json" };
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
await FsUtil.writeJsonAsync(
|
|
107
|
-
path.resolve(this._pkgPath, "dist/package.json"),
|
|
108
|
-
distNpmConfig,
|
|
109
|
-
{space: 2}
|
|
110
|
-
);
|
|
106
|
+
await FsUtil.writeJsonAsync(path.resolve(this._pkgPath, "dist/package.json"), distNpmConfig, { space: 2 });
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
this._debug("GEN openssl.cnf...");
|
|
@@ -135,11 +131,10 @@ activate = 1
|
|
|
135
131
|
system_default = system_default_sect
|
|
136
132
|
|
|
137
133
|
[system_default_sect]
|
|
138
|
-
Options = UnsafeLegacyRenegotiation`.trim()
|
|
134
|
+
Options = UnsafeLegacyRenegotiation`.trim(),
|
|
139
135
|
);
|
|
140
136
|
}
|
|
141
137
|
|
|
142
|
-
|
|
143
138
|
if (this.#pkgConf.pm2) {
|
|
144
139
|
this._debug("GEN pm2.json...");
|
|
145
140
|
|
|
@@ -150,26 +145,25 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
150
145
|
script: "main.js",
|
|
151
146
|
watch: true,
|
|
152
147
|
watch_delay: 2000,
|
|
153
|
-
ignore_watch: [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"interpreter": "node@" + process.versions.node,
|
|
160
|
-
},
|
|
148
|
+
ignore_watch: ["node_modules", "www", ...(this.#pkgConf.pm2.ignoreWatchPaths ?? [])],
|
|
149
|
+
...(this.#pkgConf.pm2.noInterpreter
|
|
150
|
+
? {}
|
|
151
|
+
: {
|
|
152
|
+
interpreter: "node@" + process.versions.node,
|
|
153
|
+
}),
|
|
161
154
|
interpreter_args: "--openssl-config=openssl.cnf",
|
|
162
155
|
env: {
|
|
163
156
|
NODE_ENV: "production",
|
|
164
157
|
TZ: "Asia/Seoul",
|
|
165
158
|
SD_VERSION: npmConfig.version,
|
|
166
|
-
...this.#pkgConf.env
|
|
159
|
+
...this.#pkgConf.env,
|
|
167
160
|
},
|
|
168
161
|
arrayProcess: "concat",
|
|
169
|
-
useDelTargetNull: true
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
useDelTargetNull: true,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
space: 2,
|
|
166
|
+
},
|
|
173
167
|
);
|
|
174
168
|
}
|
|
175
169
|
|
|
@@ -178,13 +172,17 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
178
172
|
|
|
179
173
|
const iisDistPath = path.resolve(this._pkgPath, "dist/web.config");
|
|
180
174
|
const serverExeFilePath = this.#pkgConf.iis.nodeExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe";
|
|
181
|
-
await FsUtil.writeFileAsync(
|
|
175
|
+
await FsUtil.writeFileAsync(
|
|
176
|
+
iisDistPath,
|
|
177
|
+
`
|
|
182
178
|
<configuration>
|
|
183
179
|
<appSettings>
|
|
184
180
|
<add key="NODE_ENV" value="production" />
|
|
185
181
|
<add key="TZ" value="Asia/Seoul" />
|
|
186
182
|
<add key="SD_VERSION" value="${npmConfig.version}" />
|
|
187
|
-
${Object.keys(this.#pkgConf.env ?? {})
|
|
183
|
+
${Object.keys(this.#pkgConf.env ?? {})
|
|
184
|
+
.map((key) => `<add key="${key}" value="${this.#pkgConf.env![key]}"/>`)
|
|
185
|
+
.join("\n ")}
|
|
188
186
|
</appSettings>
|
|
189
187
|
<system.webServer>
|
|
190
188
|
<handlers>
|
|
@@ -205,13 +203,14 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
205
203
|
</system.webServer>
|
|
206
204
|
</configuration>
|
|
207
205
|
|
|
208
|
-
`.trim()
|
|
206
|
+
`.trim(),
|
|
207
|
+
);
|
|
209
208
|
}
|
|
210
209
|
|
|
211
|
-
const result = await this._runAsync({dev: false});
|
|
210
|
+
const result = await this._runAsync({ dev: false });
|
|
212
211
|
return {
|
|
213
212
|
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
214
|
-
buildResults: result.buildResults
|
|
213
|
+
buildResults: result.buildResults,
|
|
215
214
|
};
|
|
216
215
|
}
|
|
217
216
|
|
|
@@ -222,70 +221,89 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
222
221
|
}> {
|
|
223
222
|
this._debug(`BUILD 준비...`);
|
|
224
223
|
const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
225
|
-
this.#extModules = this.#extModules ?? await this._getExternalModulesAsync();
|
|
226
|
-
this.#builder =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
this.#extModules = this.#extModules ?? (await this._getExternalModulesAsync());
|
|
225
|
+
this.#builder =
|
|
226
|
+
this.#builder ??
|
|
227
|
+
new SdServerBundler({
|
|
228
|
+
dev: opt.dev,
|
|
229
|
+
pkgPath: this._pkgPath,
|
|
230
|
+
entryPoints: tsConfig.files
|
|
231
|
+
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
232
|
+
: [path.resolve(this._pkgPath, "src/main.ts")],
|
|
233
|
+
external: this.#extModules.map((item) => item.name),
|
|
234
|
+
});
|
|
234
235
|
|
|
235
236
|
this._debug(`BUILD & CHECK...`);
|
|
236
237
|
const buildResult = await this.#builder.bundleAsync();
|
|
237
238
|
|
|
238
239
|
//-- filePaths
|
|
239
240
|
|
|
240
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
241
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
242
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
243
|
+
);
|
|
244
|
+
const watchFileSet = new Set(
|
|
245
|
+
Array.from(buildResult.watchFileSet).filter(
|
|
246
|
+
(item) =>
|
|
247
|
+
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
248
|
+
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
249
|
+
),
|
|
250
|
+
);
|
|
246
251
|
|
|
247
252
|
this._debug(`LINT...`);
|
|
248
|
-
const lintResults = await SdLinter.lintAsync(
|
|
253
|
+
const lintResults = await SdLinter.lintAsync(this._pkgPath, buildResult.affectedFileSet, buildResult.program);
|
|
249
254
|
|
|
250
255
|
this._debug(`빌드 완료`);
|
|
251
256
|
return {
|
|
252
257
|
watchFileSet,
|
|
253
258
|
affectedFileSet: buildResult.affectedFileSet,
|
|
254
|
-
buildResults: [...buildResult.results, ...lintResults]
|
|
259
|
+
buildResults: [...buildResult.results, ...lintResults],
|
|
255
260
|
};
|
|
256
261
|
}
|
|
257
262
|
|
|
258
|
-
private async _getExternalModulesAsync(): Promise<
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
private async _getExternalModulesAsync(): Promise<
|
|
264
|
+
{
|
|
265
|
+
name: string;
|
|
266
|
+
exists: boolean;
|
|
267
|
+
}[]
|
|
268
|
+
> {
|
|
262
269
|
const loadedModuleNames: string[] = [];
|
|
263
270
|
const results: {
|
|
264
271
|
name: string;
|
|
265
|
-
exists: boolean
|
|
272
|
+
exists: boolean;
|
|
266
273
|
}[] = [];
|
|
267
274
|
|
|
268
275
|
const npmConfigMap = new Map<string, INpmConfig>();
|
|
269
276
|
|
|
270
277
|
const fn = async (currPath: string): Promise<void> => {
|
|
271
|
-
const npmConfig = npmConfigMap.getOrCreate(
|
|
278
|
+
const npmConfig = npmConfigMap.getOrCreate(
|
|
279
|
+
currPath,
|
|
280
|
+
await FsUtil.readJsonAsync(path.resolve(currPath, "package.json")),
|
|
281
|
+
);
|
|
272
282
|
|
|
273
283
|
const deps = {
|
|
274
284
|
defaults: [
|
|
275
285
|
...Object.keys(npmConfig.dependencies ?? {}),
|
|
276
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter(
|
|
286
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter(
|
|
287
|
+
(item) => !npmConfig.peerDependenciesMeta?.[item]?.optional,
|
|
288
|
+
),
|
|
277
289
|
].distinct(),
|
|
278
290
|
optionals: [
|
|
279
291
|
...Object.keys(npmConfig.optionalDependencies ?? {}),
|
|
280
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter(
|
|
281
|
-
|
|
292
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter(
|
|
293
|
+
(item) => npmConfig.peerDependenciesMeta?.[item]?.optional,
|
|
294
|
+
),
|
|
295
|
+
].distinct(),
|
|
282
296
|
};
|
|
283
297
|
|
|
284
298
|
for (const moduleName of deps.defaults) {
|
|
285
299
|
if (loadedModuleNames.includes(moduleName)) continue;
|
|
286
300
|
loadedModuleNames.push(moduleName);
|
|
287
301
|
|
|
288
|
-
const modulePath = FsUtil.findAllParentChildPaths(
|
|
302
|
+
const modulePath = FsUtil.findAllParentChildPaths(
|
|
303
|
+
"node_modules/" + moduleName,
|
|
304
|
+
currPath,
|
|
305
|
+
path.resolve(this._pkgPath, "../../"),
|
|
306
|
+
).first();
|
|
289
307
|
if (StringUtil.isNullOrEmpty(modulePath)) {
|
|
290
308
|
continue;
|
|
291
309
|
}
|
|
@@ -293,14 +311,14 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
293
311
|
if (FsUtil.glob(path.resolve(modulePath, "binding.gyp")).length > 0) {
|
|
294
312
|
results.push({
|
|
295
313
|
name: moduleName,
|
|
296
|
-
exists: true
|
|
314
|
+
exists: true,
|
|
297
315
|
});
|
|
298
316
|
}
|
|
299
317
|
|
|
300
318
|
if (this.#pkgConf.externals?.includes(moduleName)) {
|
|
301
319
|
results.push({
|
|
302
320
|
name: moduleName,
|
|
303
|
-
exists: true
|
|
321
|
+
exists: true,
|
|
304
322
|
});
|
|
305
323
|
}
|
|
306
324
|
|
|
@@ -311,11 +329,15 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
311
329
|
if (loadedModuleNames.includes(optModuleName)) continue;
|
|
312
330
|
loadedModuleNames.push(optModuleName);
|
|
313
331
|
|
|
314
|
-
const optModulePath = FsUtil.findAllParentChildPaths(
|
|
332
|
+
const optModulePath = FsUtil.findAllParentChildPaths(
|
|
333
|
+
"node_modules/" + optModuleName,
|
|
334
|
+
currPath,
|
|
335
|
+
path.resolve(this._pkgPath, "../../"),
|
|
336
|
+
).first();
|
|
315
337
|
if (StringUtil.isNullOrEmpty(optModulePath)) {
|
|
316
338
|
results.push({
|
|
317
339
|
name: optModuleName,
|
|
318
|
-
exists: false
|
|
340
|
+
exists: false,
|
|
319
341
|
});
|
|
320
342
|
continue;
|
|
321
343
|
}
|
|
@@ -323,14 +345,14 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
323
345
|
if (FsUtil.glob(path.resolve(optModulePath, "binding.gyp")).length > 0) {
|
|
324
346
|
results.push({
|
|
325
347
|
name: optModuleName,
|
|
326
|
-
exists: true
|
|
348
|
+
exists: true,
|
|
327
349
|
});
|
|
328
350
|
}
|
|
329
351
|
|
|
330
352
|
if (this.#pkgConf.externals?.includes(optModuleName)) {
|
|
331
353
|
results.push({
|
|
332
354
|
name: optModuleName,
|
|
333
|
-
exists: true
|
|
355
|
+
exists: true,
|
|
334
356
|
});
|
|
335
357
|
}
|
|
336
358
|
|
|
@@ -341,10 +363,10 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
341
363
|
await fn(this._pkgPath);
|
|
342
364
|
|
|
343
365
|
for (const external of this.#pkgConf.externals ?? []) {
|
|
344
|
-
if (!results.some(item => item.name === external)) {
|
|
366
|
+
if (!results.some((item) => item.name === external)) {
|
|
345
367
|
results.push({
|
|
346
368
|
name: external,
|
|
347
|
-
exists: false
|
|
369
|
+
exists: false,
|
|
348
370
|
});
|
|
349
371
|
}
|
|
350
372
|
}
|
|
@@ -93,10 +93,10 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
93
93
|
const buildResult = await this.#bundler.buildAsync();
|
|
94
94
|
|
|
95
95
|
this._debug("LINT...");
|
|
96
|
-
const lintFilePaths = Array.from(buildResult.affectedFileSet).filter((item) =>
|
|
96
|
+
/*const lintFilePaths = Array.from(buildResult.affectedFileSet).filter((item) =>
|
|
97
97
|
PathUtil.isChildPath(item, this.#pkgPath),
|
|
98
|
-
)
|
|
99
|
-
const lintResults = await SdLinter.lintAsync(
|
|
98
|
+
);*/
|
|
99
|
+
const lintResults = await SdLinter.lintAsync(this.#pkgPath, buildResult.affectedFileSet, buildResult.program);
|
|
100
100
|
|
|
101
101
|
this._debug(`빌드 완료`);
|
|
102
102
|
const localUpdatePaths = Object.keys(this.#projConf.localUpdates ?? {}).mapMany((key) =>
|
|
@@ -15,7 +15,12 @@ export function sdNgPlugin(conf: {
|
|
|
15
15
|
return {
|
|
16
16
|
name: "sd-ng-compiler",
|
|
17
17
|
setup: (build: esbuild.PluginBuild) => {
|
|
18
|
-
const compiler = new SdTsCompiler(
|
|
18
|
+
const compiler = new SdTsCompiler({
|
|
19
|
+
pkgPath: conf.pkgPath,
|
|
20
|
+
additionalOptions: { declaration: false },
|
|
21
|
+
isDevMode: conf.dev,
|
|
22
|
+
isForBundle: true,
|
|
23
|
+
});
|
|
19
24
|
|
|
20
25
|
let buildResult: ISdTsCompilerResult;
|
|
21
26
|
const outputContentsCacheMap = new Map<string, Uint8Array>();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import {ISdTsCompilerResult, SdTsCompiler} from "../build-tools/SdTsCompiler";
|
|
5
|
-
import {convertTypeScriptDiagnostic} from "@angular/build/src/tools/esbuild/angular/diagnostics";
|
|
4
|
+
import { ISdTsCompilerResult, SdTsCompiler } from "../build-tools/SdTsCompiler";
|
|
5
|
+
import { convertTypeScriptDiagnostic } from "@angular/build/src/tools/esbuild/angular/diagnostics";
|
|
6
6
|
|
|
7
7
|
export function sdServerPlugin(conf: {
|
|
8
8
|
pkgPath: string;
|
|
@@ -13,7 +13,12 @@ export function sdServerPlugin(conf: {
|
|
|
13
13
|
return {
|
|
14
14
|
name: "sd-server-compiler",
|
|
15
15
|
setup: (build: esbuild.PluginBuild) => {
|
|
16
|
-
const compiler = new SdTsCompiler(
|
|
16
|
+
const compiler = new SdTsCompiler({
|
|
17
|
+
pkgPath: conf.pkgPath,
|
|
18
|
+
additionalOptions: { declaration: false },
|
|
19
|
+
isDevMode: conf.dev,
|
|
20
|
+
isForBundle: true,
|
|
21
|
+
});
|
|
17
22
|
|
|
18
23
|
let buildResult: ISdTsCompilerResult;
|
|
19
24
|
|
|
@@ -28,33 +33,44 @@ export function sdServerPlugin(conf: {
|
|
|
28
33
|
//-- return err/warn
|
|
29
34
|
|
|
30
35
|
return {
|
|
31
|
-
errors: buildResult.typescriptDiagnostics
|
|
32
|
-
|
|
36
|
+
errors: buildResult.typescriptDiagnostics
|
|
37
|
+
.filter((item) => item.category === ts.DiagnosticCategory.Error)
|
|
38
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
39
|
+
warnings: buildResult.typescriptDiagnostics
|
|
40
|
+
.filter((item) => item.category !== ts.DiagnosticCategory.Error)
|
|
41
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
33
42
|
};
|
|
34
43
|
});
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
build.onLoad({filter: /\.ts$/}, (args) => {
|
|
45
|
+
build.onLoad({ filter: /\.ts$/ }, (args) => {
|
|
38
46
|
const emittedJsFile = buildResult.emittedFilesCacheMap.get(path.normalize(args.path))?.last();
|
|
39
47
|
if (!emittedJsFile) {
|
|
40
48
|
throw new Error(`ts 빌더 결과 emit 파일이 존재하지 않습니다. ${args.path}`);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
const contents = emittedJsFile.text;
|
|
44
|
-
return {contents, loader: "js"};
|
|
52
|
+
return { contents, loader: "js" };
|
|
45
53
|
});
|
|
46
54
|
|
|
47
|
-
build.onLoad({filter: /\.[cm]?js$/}, (args) => {
|
|
55
|
+
build.onLoad({ filter: /\.[cm]?js$/ }, (args) => {
|
|
48
56
|
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
49
57
|
return null;
|
|
50
58
|
});
|
|
51
59
|
|
|
52
60
|
build.onLoad(
|
|
53
|
-
{
|
|
61
|
+
{
|
|
62
|
+
filter: new RegExp(
|
|
63
|
+
"(" +
|
|
64
|
+
Object.keys(build.initialOptions.loader!)
|
|
65
|
+
.map((item) => "\\" + item)
|
|
66
|
+
.join("|") +
|
|
67
|
+
")$",
|
|
68
|
+
),
|
|
69
|
+
},
|
|
54
70
|
(args) => {
|
|
55
71
|
conf.result.watchFileSet!.add(path.normalize(args.path));
|
|
56
72
|
return null;
|
|
57
|
-
}
|
|
73
|
+
},
|
|
58
74
|
);
|
|
59
75
|
|
|
60
76
|
build.onEnd((result) => {
|
|
@@ -63,7 +79,7 @@ export function sdServerPlugin(conf: {
|
|
|
63
79
|
|
|
64
80
|
conf.modifiedFileSet.clear();
|
|
65
81
|
});
|
|
66
|
-
}
|
|
82
|
+
},
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
85
|
|
|
@@ -73,4 +89,4 @@ export interface IServerPluginResultCache {
|
|
|
73
89
|
outputFiles?: esbuild.OutputFile[];
|
|
74
90
|
metafile?: esbuild.Metafile;
|
|
75
91
|
program?: ts.Program;
|
|
76
|
-
}
|
|
92
|
+
}
|
|
@@ -28,7 +28,7 @@ export class SdCliElectron {
|
|
|
28
28
|
const externalPkgNames = pkgConf.builder.electron.reinstallDependencies ?? [];
|
|
29
29
|
|
|
30
30
|
await FsUtil.writeJsonAsync(path.resolve(electronPath, `package.json`), {
|
|
31
|
-
name: npmConfig.name,
|
|
31
|
+
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
32
32
|
version: npmConfig.version,
|
|
33
33
|
description: npmConfig.description,
|
|
34
34
|
main: "electron-main.js",
|
|
@@ -78,7 +78,7 @@ export class SdCliElectron {
|
|
|
78
78
|
const externalPkgNames = pkgConf.builder.electron.reinstallDependencies ?? [];
|
|
79
79
|
|
|
80
80
|
await FsUtil.writeJsonAsync(path.resolve(electronPath, `package.json`), {
|
|
81
|
-
name: npmConfig.name,
|
|
81
|
+
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
82
82
|
version: npmConfig.version,
|
|
83
83
|
description: npmConfig.description,
|
|
84
84
|
main: "electron-main.js",
|
|
@@ -107,7 +107,7 @@ export class SdCliElectron {
|
|
|
107
107
|
config: {
|
|
108
108
|
appId: pkgConf.builder.electron.appId,
|
|
109
109
|
productName: npmConfig.description,
|
|
110
|
-
|
|
110
|
+
asar: false,
|
|
111
111
|
win: {
|
|
112
112
|
target: "nsis"
|
|
113
113
|
},
|
|
@@ -144,7 +144,7 @@ export class SdCliElectron {
|
|
|
144
144
|
const externalPkgNames = opt.config.reinstallDependencies ?? [];
|
|
145
145
|
|
|
146
146
|
await FsUtil.writeJsonAsync(path.resolve(electronSrcPath, `package.json`), {
|
|
147
|
-
name: npmConfig.name,
|
|
147
|
+
name: npmConfig.name.replace(/^@/, "").replace(/\//, "-"),
|
|
148
148
|
version: npmConfig.version,
|
|
149
149
|
description: npmConfig.description,
|
|
150
150
|
main: "electron-main.js",
|
|
@@ -173,7 +173,7 @@ export class SdCliElectron {
|
|
|
173
173
|
config: {
|
|
174
174
|
appId: opt.config.appId,
|
|
175
175
|
productName: npmConfig.description,
|
|
176
|
-
|
|
176
|
+
asar: false,
|
|
177
177
|
win: {
|
|
178
178
|
target: "nsis"
|
|
179
179
|
},
|
|
@@ -100,8 +100,10 @@ export class SdCliProject {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
for (const buildResult of message.result!.buildResults) {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
if (buildResult.filePath == null || PathUtil.isChildPath(buildResult.filePath, message.req.pkgPath)) {
|
|
104
|
+
const cacheItem = resultCache.getOrCreate(buildResult.filePath ?? "none", []);
|
|
105
|
+
cacheItem.push(buildResult);
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
const pkgConf = message.req.projConf.packages[path.basename(message.req.pkgPath)]!;
|