@simplysm/sd-cli 7.0.247 → 7.0.263
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/README.md +48 -0
- package/dist/bin/sd-cli.mjs +171 -13
- package/dist/build-tool/SdCliElectron.mjs +3 -2
- package/dist/builder/SdCliClientBuilder.mjs +33 -35
- package/dist/builder/SdCliServerBuilder.d.ts +1 -0
- package/dist/builder/SdCliServerBuilder.mjs +58 -22
- package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
- package/dist/commons.d.ts +9 -1
- package/dist/entry-points/SdCliProjectGenerator.d.ts +37 -0
- package/dist/entry-points/SdCliProjectGenerator.mjs +288 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +6 -3
- package/dist/entry-points/SdCliWorkspace.mjs +147 -120
- package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +3 -0
- package/dist/entry-points/file/base/fc_package_eslintrc.mjs +31 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +9 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +32 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +4 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.mjs +12 -0
- package/dist/entry-points/file/client/fc_package_AppModule.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppModule.mjs +37 -0
- package/dist/entry-points/file/client/fc_package_AppPage.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppPage.mjs +34 -0
- package/dist/entry-points/file/client/fc_package_appicons.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_appicons.mjs +6 -0
- package/dist/entry-points/file/client/fc_package_client_main.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_client_main.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_index.d.ts +3 -0
- package/dist/entry-points/file/client/fc_package_index.mjs +88 -0
- package/dist/entry-points/file/client/fc_package_manifest.d.ts +5 -0
- package/dist/entry-points/file/client/fc_package_manifest.mjs +54 -0
- package/dist/entry-points/file/client/fc_package_polyfills.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_polyfills.mjs +11 -0
- package/dist/entry-points/file/client/fc_package_styles.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_styles.mjs +7 -0
- package/dist/entry-points/file/db/fc_package_DbContext.d.ts +3 -0
- package/dist/entry-points/file/db/fc_package_DbContext.mjs +14 -0
- package/dist/entry-points/file/db/fc_package_DbModel.d.ts +4 -0
- package/dist/entry-points/file/db/fc_package_DbModel.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_editor_config.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_editor_config.mjs +22 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.mjs +30 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.mjs +6 -0
- package/dist/entry-points/file/project/fc_project_gitignore.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +17 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +7 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +35 -0
- package/dist/entry-points/file/project/fc_project_readme.d.ts +3 -0
- package/dist/entry-points/file/project/fc_project_readme.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_simplysm.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_simplysm.mjs +2 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +26 -0
- package/dist/entry-points/file/server/fc_package_server_main.d.ts +4 -0
- package/dist/entry-points/file/server/fc_package_server_main.mjs +60 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +24 -1
- package/dist/packages/SdCliPackage.d.ts +1 -0
- package/dist/packages/SdCliPackage.mjs +68 -62
- package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
- package/dist/worker/server-worker.d.ts +1 -0
- package/dist/worker/server-worker.mjs +67 -0
- package/package.json +10 -8
- package/src/bin/sd-cli.ts +198 -12
- package/src/build-tool/SdCliElectron.ts +2 -1
- package/src/builder/SdCliClientBuilder.ts +36 -36
- package/src/builder/SdCliJsLibBuilder.ts +70 -70
- package/src/builder/SdCliServerBuilder.ts +58 -20
- package/src/builder/SdCliTsLibBuilder.ts +450 -445
- package/src/commons.ts +7 -1
- package/src/entry-points/SdCliProjectGenerator.ts +353 -0
- package/src/entry-points/SdCliWorkspace.ts +171 -137
- package/src/entry-points/file/assets/assets/icons/icon-128x128.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-144x144.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-152x152.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-192x192.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-384x384.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-512x512.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-72x72.png +0 -0
- package/src/entry-points/file/assets/assets/icons/icon-96x96.png +0 -0
- package/src/entry-points/file/assets/favicon.ico +0 -0
- package/src/entry-points/file/base/fc_package_eslintrc.ts +30 -0
- package/src/entry-points/file/base/fc_package_npmconfig.ts +43 -0
- package/src/entry-points/file/base/fc_package_tsconfig.ts +11 -0
- package/src/entry-points/file/client/fc_package_AppModule.ts +36 -0
- package/src/entry-points/file/client/fc_package_AppPage.ts +33 -0
- package/src/entry-points/file/client/fc_package_appicons.ts +5 -0
- package/src/entry-points/file/client/fc_package_client_main.ts +18 -0
- package/src/entry-points/file/client/fc_package_index.ts +87 -0
- package/src/entry-points/file/client/fc_package_manifest.ts +53 -0
- package/src/entry-points/file/client/fc_package_polyfills.ts +10 -0
- package/src/entry-points/file/client/fc_package_styles.ts +6 -0
- package/src/entry-points/file/db/fc_package_DbContext.ts +14 -0
- package/src/entry-points/file/db/fc_package_DbModel.ts +11 -0
- package/src/entry-points/file/project/fc_project_editor_config.ts +21 -0
- package/src/entry-points/file/project/fc_project_eslintrc.ts +29 -0
- package/src/entry-points/file/project/fc_project_gitattributes.ts +5 -0
- package/src/entry-points/file/project/fc_project_gitignore.ts +16 -0
- package/src/entry-points/file/project/fc_project_npmconfig.ts +34 -0
- package/src/entry-points/file/project/fc_project_readme.ts +11 -0
- package/src/entry-points/file/project/fc_project_simplysm.ts +1 -0
- package/src/entry-points/file/project/fc_project_tsconfig.ts +25 -0
- package/src/entry-points/file/server/fc_package_server_main.ts +62 -0
- package/src/index.ts +23 -0
- package/src/packages/SdCliPackage.ts +75 -58
- package/src/utils/SdCliBuildResultUtil.ts +76 -76
- package/src/worker/server-worker.ts +72 -0
- package/tsconfig-build.json +2 -1
- package/tsconfig.json +2 -1
|
@@ -1,445 +1,450 @@
|
|
|
1
|
-
import { INpmConfig, ISdCliLibPackageConfig, ISdCliPackageBuildResult } from "../commons";
|
|
2
|
-
import { EventEmitter } from "events";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { createHash } from "crypto";
|
|
7
|
-
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
8
|
-
import { NgtscProgram } from "@angular/compiler-cli";
|
|
9
|
-
import sass from "sass";
|
|
10
|
-
import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
|
|
11
|
-
import { SdCliCacheCompilerHost } from "../build-tool/SdCliCacheCompilerHost";
|
|
12
|
-
import { SdCliNgCacheCompilerHost } from "../build-tool/SdCliNgCacheCompilerHost";
|
|
13
|
-
import { NgCompiler } from "@angular/compiler-cli/src/ngtsc/core";
|
|
14
|
-
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
15
|
-
import { SdCliNgModuleGenerator } from "../ng-tools/SdCliNgModuleGenerator";
|
|
16
|
-
import { SdCliIndexFileGenerator } from "../build-tool/SdCliIndexFileGenerator";
|
|
17
|
-
|
|
18
|
-
export class SdCliTsLibBuilder extends EventEmitter {
|
|
19
|
-
private readonly _logger: Logger;
|
|
20
|
-
|
|
21
|
-
private _moduleResolutionCache?: ts.ModuleResolutionCache;
|
|
22
|
-
|
|
23
|
-
private readonly _linter: SdCliPackageLinter;
|
|
24
|
-
|
|
25
|
-
private readonly _fileCache = new Map<string, IFileCache>();
|
|
26
|
-
private readonly _writeFileCache = new Map<string, string>();
|
|
27
|
-
|
|
28
|
-
private readonly _indexFileGenerator?: SdCliIndexFileGenerator;
|
|
29
|
-
|
|
30
|
-
private _program?: ts.Program;
|
|
31
|
-
private _ngProgram?: NgtscProgram;
|
|
32
|
-
private _builder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
33
|
-
private readonly _ngModuleGenerator?: SdCliNgModuleGenerator;
|
|
34
|
-
|
|
35
|
-
private readonly _tsconfigFilePath: string;
|
|
36
|
-
private readonly _parsedTsconfig: ts.ParsedCommandLine;
|
|
37
|
-
private readonly _npmConfigMap = new Map<string, INpmConfig>();
|
|
38
|
-
|
|
39
|
-
private readonly _isAngular: boolean;
|
|
40
|
-
private readonly _hasAngularRoute: boolean;
|
|
41
|
-
|
|
42
|
-
public constructor(private readonly _rootPath: string,
|
|
43
|
-
private readonly _config: ISdCliLibPackageConfig,
|
|
44
|
-
private readonly _workspaceRootPath: string) {
|
|
45
|
-
super();
|
|
46
|
-
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
47
|
-
|
|
48
|
-
// linter
|
|
49
|
-
this._linter = new SdCliPackageLinter(this._rootPath);
|
|
50
|
-
|
|
51
|
-
// logger
|
|
52
|
-
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, npmConfig.name]);
|
|
53
|
-
|
|
54
|
-
// isAngular
|
|
55
|
-
this._isAngular = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/core");
|
|
56
|
-
this._hasAngularRoute = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/router");
|
|
57
|
-
|
|
58
|
-
// tsconfig
|
|
59
|
-
this._tsconfigFilePath = path.resolve(this._rootPath, "tsconfig-build.json");
|
|
60
|
-
const tsconfig = FsUtil.readJson(this._tsconfigFilePath);
|
|
61
|
-
this._parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._rootPath, this._isAngular ? tsconfig.angularCompilerOptions : undefined);
|
|
62
|
-
|
|
63
|
-
if (this._isAngular) {
|
|
64
|
-
// NgModule 생성기 초기화
|
|
65
|
-
this._ngModuleGenerator = new SdCliNgModuleGenerator(this._rootPath, [
|
|
66
|
-
"controls",
|
|
67
|
-
"directives",
|
|
68
|
-
"guards",
|
|
69
|
-
"modals",
|
|
70
|
-
"providers",
|
|
71
|
-
"app",
|
|
72
|
-
"pages",
|
|
73
|
-
"print-templates",
|
|
74
|
-
"toasts",
|
|
75
|
-
"AppPage"
|
|
76
|
-
], this._hasAngularRoute ? {
|
|
77
|
-
glob: "**/*Page.ts",
|
|
78
|
-
fileEndsWith: "Page",
|
|
79
|
-
rootClassName: "AppPage"
|
|
80
|
-
} : undefined);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// index 생성기 초기화
|
|
84
|
-
if (this._config.autoIndex) {
|
|
85
|
-
this._indexFileGenerator = new SdCliIndexFileGenerator(this._rootPath, this._config.autoIndex);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public override on(event: "change", listener: () => void): this;
|
|
90
|
-
public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
|
|
91
|
-
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
92
|
-
return super.on(event, listener);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public async watchAsync(): Promise<void> {
|
|
96
|
-
this.emit("change");
|
|
97
|
-
|
|
98
|
-
this._logger.debug("dist 폴더 삭제...");
|
|
99
|
-
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
100
|
-
|
|
101
|
-
if (this._ngModuleGenerator) {
|
|
102
|
-
this._logger.debug("NgModule 생성...");
|
|
103
|
-
await this._ngModuleGenerator.runAsync();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (this._indexFileGenerator) {
|
|
107
|
-
this._logger.debug("index.js 생성 및 index.js용 변경감지 시작...");
|
|
108
|
-
await this._indexFileGenerator.runAsync();
|
|
109
|
-
await this._indexFileGenerator.watchAsync();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this._logger.debug("프로그램 로딩...");
|
|
113
|
-
const buildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
114
|
-
|
|
115
|
-
this._logger.debug("변경감지 구성...");
|
|
116
|
-
const relatedPaths = await this.getAllRelatedPathsAsync();
|
|
117
|
-
const watcher = SdFsWatcher.watch(relatedPaths);
|
|
118
|
-
watcher.onChange({}, async (changedInfos) => {
|
|
119
|
-
const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
|
|
120
|
-
if (changeFilePaths.length === 0) return;
|
|
121
|
-
|
|
122
|
-
this._logger.debug("파일 변경 감지", changeFilePaths);
|
|
123
|
-
this.emit("change");
|
|
124
|
-
|
|
125
|
-
this._logger.debug("변경된 파일의 캐쉬 삭제...");
|
|
126
|
-
for (const changeFilePath of changeFilePaths) {
|
|
127
|
-
const fileCache = this._fileCache.get(PathUtil.posix(changeFilePath));
|
|
128
|
-
if (fileCache) {
|
|
129
|
-
if (fileCache.importerSet) {
|
|
130
|
-
for (const importer of fileCache.importerSet.values()) {
|
|
131
|
-
this._fileCache.delete(importer);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
this._fileCache.delete(PathUtil.posix(changeFilePath));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (this._ngModuleGenerator) {
|
|
140
|
-
this._logger.debug("NgModule 생성...");
|
|
141
|
-
this._ngModuleGenerator.removeCaches(changeFilePaths);
|
|
142
|
-
await this._ngModuleGenerator.runAsync();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const watchBuildResults: ISdCliPackageBuildResult[] = [];
|
|
146
|
-
|
|
147
|
-
this._logger.debug("프로그램 로딩...");
|
|
148
|
-
const watchBuildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
...
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
this._moduleResolutionCache,
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1
|
+
import { INpmConfig, ISdCliLibPackageConfig, ISdCliPackageBuildResult } from "../commons";
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { createHash } from "crypto";
|
|
7
|
+
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
8
|
+
import { NgtscProgram } from "@angular/compiler-cli";
|
|
9
|
+
import sass from "sass";
|
|
10
|
+
import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
|
|
11
|
+
import { SdCliCacheCompilerHost } from "../build-tool/SdCliCacheCompilerHost";
|
|
12
|
+
import { SdCliNgCacheCompilerHost } from "../build-tool/SdCliNgCacheCompilerHost";
|
|
13
|
+
import { NgCompiler } from "@angular/compiler-cli/src/ngtsc/core";
|
|
14
|
+
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
15
|
+
import { SdCliNgModuleGenerator } from "../ng-tools/SdCliNgModuleGenerator";
|
|
16
|
+
import { SdCliIndexFileGenerator } from "../build-tool/SdCliIndexFileGenerator";
|
|
17
|
+
|
|
18
|
+
export class SdCliTsLibBuilder extends EventEmitter {
|
|
19
|
+
private readonly _logger: Logger;
|
|
20
|
+
|
|
21
|
+
private _moduleResolutionCache?: ts.ModuleResolutionCache;
|
|
22
|
+
|
|
23
|
+
private readonly _linter: SdCliPackageLinter;
|
|
24
|
+
|
|
25
|
+
private readonly _fileCache = new Map<string, IFileCache>();
|
|
26
|
+
private readonly _writeFileCache = new Map<string, string>();
|
|
27
|
+
|
|
28
|
+
private readonly _indexFileGenerator?: SdCliIndexFileGenerator;
|
|
29
|
+
|
|
30
|
+
private _program?: ts.Program;
|
|
31
|
+
private _ngProgram?: NgtscProgram;
|
|
32
|
+
private _builder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
33
|
+
private readonly _ngModuleGenerator?: SdCliNgModuleGenerator;
|
|
34
|
+
|
|
35
|
+
private readonly _tsconfigFilePath: string;
|
|
36
|
+
private readonly _parsedTsconfig: ts.ParsedCommandLine;
|
|
37
|
+
private readonly _npmConfigMap = new Map<string, INpmConfig>();
|
|
38
|
+
|
|
39
|
+
private readonly _isAngular: boolean;
|
|
40
|
+
private readonly _hasAngularRoute: boolean;
|
|
41
|
+
|
|
42
|
+
public constructor(private readonly _rootPath: string,
|
|
43
|
+
private readonly _config: ISdCliLibPackageConfig,
|
|
44
|
+
private readonly _workspaceRootPath: string) {
|
|
45
|
+
super();
|
|
46
|
+
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
47
|
+
|
|
48
|
+
// linter
|
|
49
|
+
this._linter = new SdCliPackageLinter(this._rootPath);
|
|
50
|
+
|
|
51
|
+
// logger
|
|
52
|
+
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, npmConfig.name]);
|
|
53
|
+
|
|
54
|
+
// isAngular
|
|
55
|
+
this._isAngular = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/core");
|
|
56
|
+
this._hasAngularRoute = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/router");
|
|
57
|
+
|
|
58
|
+
// tsconfig
|
|
59
|
+
this._tsconfigFilePath = path.resolve(this._rootPath, "tsconfig-build.json");
|
|
60
|
+
const tsconfig = FsUtil.readJson(this._tsconfigFilePath);
|
|
61
|
+
this._parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._rootPath, this._isAngular ? tsconfig.angularCompilerOptions : undefined);
|
|
62
|
+
|
|
63
|
+
if (this._isAngular) {
|
|
64
|
+
// NgModule 생성기 초기화
|
|
65
|
+
this._ngModuleGenerator = new SdCliNgModuleGenerator(this._rootPath, [
|
|
66
|
+
"controls",
|
|
67
|
+
"directives",
|
|
68
|
+
"guards",
|
|
69
|
+
"modals",
|
|
70
|
+
"providers",
|
|
71
|
+
"app",
|
|
72
|
+
"pages",
|
|
73
|
+
"print-templates",
|
|
74
|
+
"toasts",
|
|
75
|
+
"AppPage"
|
|
76
|
+
], this._hasAngularRoute ? {
|
|
77
|
+
glob: "**/*Page.ts",
|
|
78
|
+
fileEndsWith: "Page",
|
|
79
|
+
rootClassName: "AppPage"
|
|
80
|
+
} : undefined);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// index 생성기 초기화
|
|
84
|
+
if (this._config.autoIndex) {
|
|
85
|
+
this._indexFileGenerator = new SdCliIndexFileGenerator(this._rootPath, this._config.autoIndex);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public override on(event: "change", listener: () => void): this;
|
|
90
|
+
public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
|
|
91
|
+
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
92
|
+
return super.on(event, listener);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public async watchAsync(): Promise<void> {
|
|
96
|
+
this.emit("change");
|
|
97
|
+
|
|
98
|
+
this._logger.debug("dist 폴더 삭제...");
|
|
99
|
+
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
100
|
+
|
|
101
|
+
if (this._ngModuleGenerator) {
|
|
102
|
+
this._logger.debug("NgModule 생성...");
|
|
103
|
+
await this._ngModuleGenerator.runAsync();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (this._indexFileGenerator) {
|
|
107
|
+
this._logger.debug("index.js 생성 및 index.js용 변경감지 시작...");
|
|
108
|
+
await this._indexFileGenerator.runAsync();
|
|
109
|
+
await this._indexFileGenerator.watchAsync();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this._logger.debug("프로그램 로딩...");
|
|
113
|
+
const buildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
114
|
+
|
|
115
|
+
this._logger.debug("변경감지 구성...");
|
|
116
|
+
const relatedPaths = await this.getAllRelatedPathsAsync();
|
|
117
|
+
const watcher = SdFsWatcher.watch(relatedPaths);
|
|
118
|
+
watcher.onChange({}, async (changedInfos) => {
|
|
119
|
+
const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
|
|
120
|
+
if (changeFilePaths.length === 0) return;
|
|
121
|
+
|
|
122
|
+
this._logger.debug("파일 변경 감지", changeFilePaths);
|
|
123
|
+
this.emit("change");
|
|
124
|
+
|
|
125
|
+
this._logger.debug("변경된 파일의 캐쉬 삭제...");
|
|
126
|
+
for (const changeFilePath of changeFilePaths) {
|
|
127
|
+
const fileCache = this._fileCache.get(PathUtil.posix(changeFilePath));
|
|
128
|
+
if (fileCache) {
|
|
129
|
+
if (fileCache.importerSet) {
|
|
130
|
+
for (const importer of fileCache.importerSet.values()) {
|
|
131
|
+
this._fileCache.delete(importer);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._fileCache.delete(PathUtil.posix(changeFilePath));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this._ngModuleGenerator) {
|
|
140
|
+
this._logger.debug("NgModule 생성...");
|
|
141
|
+
this._ngModuleGenerator.removeCaches(changeFilePaths);
|
|
142
|
+
await this._ngModuleGenerator.runAsync();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const watchBuildResults: ISdCliPackageBuildResult[] = [];
|
|
146
|
+
|
|
147
|
+
this._logger.debug("프로그램 로딩...");
|
|
148
|
+
const watchBuildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
149
|
+
|
|
150
|
+
const promises: Promise<ISdCliPackageBuildResult[]>[] = [];
|
|
151
|
+
|
|
152
|
+
// 빌드
|
|
153
|
+
promises.push(this._runBuilderAsync(watchBuildPack.builder, watchBuildPack.ngCompiler));
|
|
154
|
+
// watchBuildResults.push(...await this._runBuilderAsync(watchBuildPack.builder, watchBuildPack.ngCompiler));
|
|
155
|
+
|
|
156
|
+
// 린트
|
|
157
|
+
const lintFilePaths = [
|
|
158
|
+
...watchBuildPack.affectedSourceFiles.map((item) => item.fileName),
|
|
159
|
+
...changedInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path)
|
|
160
|
+
];
|
|
161
|
+
if (lintFilePaths.length > 0) {
|
|
162
|
+
promises.push(this._linter.lintAsync(lintFilePaths, watchBuildPack.program));
|
|
163
|
+
// watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths, watchBuildPack.program));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this._logger.debug("빌드...");
|
|
167
|
+
watchBuildResults.push(...(await Promise.all(promises)).mapMany());
|
|
168
|
+
|
|
169
|
+
this._logger.debug("변경감지 대상목록 재구성...");
|
|
170
|
+
const watchRelatedPaths = await this.getAllRelatedPathsAsync();
|
|
171
|
+
watcher.add(watchRelatedPaths);
|
|
172
|
+
|
|
173
|
+
this.emit("complete", watchBuildResults);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this._logger.debug("빌드...");
|
|
177
|
+
const buildResults = (await Promise.all([
|
|
178
|
+
this._runBuilderAsync(buildPack.builder, buildPack.ngCompiler),
|
|
179
|
+
this._linter.lintAsync(relatedPaths, buildPack.program)
|
|
180
|
+
].filterExists())).mapMany();
|
|
181
|
+
|
|
182
|
+
this._logger.debug("변경감지 대상목록 재구성...");
|
|
183
|
+
const watchRelatedPaths = await this.getAllRelatedPathsAsync();
|
|
184
|
+
watcher.add(watchRelatedPaths);
|
|
185
|
+
|
|
186
|
+
this.emit("complete", buildResults);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
|
|
190
|
+
this._logger.debug("dist 폴더 삭제...");
|
|
191
|
+
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
192
|
+
|
|
193
|
+
if (this._ngModuleGenerator) {
|
|
194
|
+
this._logger.debug("NgModule 생성...");
|
|
195
|
+
await this._ngModuleGenerator.runAsync();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (this._indexFileGenerator) {
|
|
199
|
+
this._logger.debug("index.js 생성...");
|
|
200
|
+
await this._indexFileGenerator.runAsync();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this._logger.debug("프로그램 로딩...");
|
|
204
|
+
const buildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
205
|
+
|
|
206
|
+
this._logger.debug("빌드...");
|
|
207
|
+
const relatedPaths = await this.getAllRelatedPathsAsync();
|
|
208
|
+
return (await Promise.all([
|
|
209
|
+
this._runBuilderAsync(buildPack.builder, buildPack.ngCompiler),
|
|
210
|
+
this._linter.lintAsync(relatedPaths, buildPack.program)
|
|
211
|
+
].filterExists())).mapMany();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private async getAllRelatedPathsAsync(): Promise<string[]> {
|
|
215
|
+
const workspaceNpmConfig = this._getNpmConfig(this._workspaceRootPath)!;
|
|
216
|
+
const workspaceName = workspaceNpmConfig.name;
|
|
217
|
+
|
|
218
|
+
const fileCachePaths = Array.from(this._fileCache.keys())
|
|
219
|
+
.filter((filePath) => {
|
|
220
|
+
const workspaceRegex = new RegExp(`node_modules[\\\\/]@${workspaceName}[\\\\/]`);
|
|
221
|
+
return !filePath.includes("node_modules")
|
|
222
|
+
|| (/node_modules[\\/]@simplysm[\\/]/).test(filePath)
|
|
223
|
+
|| workspaceRegex.test(filePath);
|
|
224
|
+
});
|
|
225
|
+
const mySourceGlobPath = path.resolve(this._rootPath, "**", "+(*.js|*.cjs|*.mjs|*.ts|*.scss)");
|
|
226
|
+
const mySourceFilePaths = await FsUtil.globAsync(mySourceGlobPath, {
|
|
227
|
+
ignore: [
|
|
228
|
+
"**/node_modules/**",
|
|
229
|
+
"**/dist/**",
|
|
230
|
+
"**/.*/**"
|
|
231
|
+
]
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return [...fileCachePaths, ...mySourceFilePaths, path.resolve(this._rootPath, ".eslintrc.cjs")].distinct();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private async _runBuilderAsync(builder: ts.EmitAndSemanticDiagnosticsBuilderProgram, ngCompiler?: NgCompiler): Promise<ISdCliPackageBuildResult[]> {
|
|
238
|
+
try {
|
|
239
|
+
const results: ISdCliPackageBuildResult[] = [];
|
|
240
|
+
|
|
241
|
+
const diagnostics: ts.Diagnostic[] = [];
|
|
242
|
+
|
|
243
|
+
if (ngCompiler) {
|
|
244
|
+
diagnostics.push(...ngCompiler.getOptionDiagnostics());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
diagnostics.push(
|
|
248
|
+
...builder.getOptionsDiagnostics(),
|
|
249
|
+
...builder.getGlobalDiagnostics()
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
if (ngCompiler) {
|
|
253
|
+
await ngCompiler.analyzeAsync();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
for (const sourceFile of builder.getSourceFiles()) {
|
|
257
|
+
if (ngCompiler?.ignoreForDiagnostics.has(sourceFile)) continue;
|
|
258
|
+
|
|
259
|
+
diagnostics.push(
|
|
260
|
+
...builder.getSyntacticDiagnostics(sourceFile),
|
|
261
|
+
...builder.getSemanticDiagnostics(sourceFile)
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
if (
|
|
265
|
+
ngCompiler &&
|
|
266
|
+
!sourceFile.isDeclarationFile &&
|
|
267
|
+
!ngCompiler.ignoreForEmit.has(sourceFile) &&
|
|
268
|
+
!ngCompiler.incrementalDriver.safeToSkipEmit(sourceFile)
|
|
269
|
+
) {
|
|
270
|
+
diagnostics.push(
|
|
271
|
+
...ngCompiler.getDiagnosticsForFile(sourceFile, 1)
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
results.push(
|
|
277
|
+
...diagnostics
|
|
278
|
+
.filter((item) => [ts.DiagnosticCategory.Error, ts.DiagnosticCategory.Warning].includes(item.category))
|
|
279
|
+
.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item))
|
|
280
|
+
.filterExists()
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
if (results.some((item) => item.severity === "error")) {
|
|
284
|
+
return results;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const transformers = ngCompiler?.prepareEmit().transformers;
|
|
288
|
+
for (const sourceFile of builder.getSourceFiles()) {
|
|
289
|
+
if (ngCompiler?.ignoreForEmit.has(sourceFile)) continue;
|
|
290
|
+
builder.emit(sourceFile, undefined, undefined, undefined, transformers);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return results;
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
if (err instanceof sass.Exception) {
|
|
297
|
+
const matches = (/^(.*\.sd\.scss) ([0-9]*):([0-9]*)/).exec(err.sassStack)!;
|
|
298
|
+
const filePath = path.resolve(matches[1].replace(/\.sd\.scss/, "").replace(/^\.:/, item => item.toUpperCase()));
|
|
299
|
+
const scssLine = matches[2];
|
|
300
|
+
const scssChar = matches[3];
|
|
301
|
+
const message = err.sassMessage;
|
|
302
|
+
|
|
303
|
+
return [{
|
|
304
|
+
filePath,
|
|
305
|
+
line: undefined,
|
|
306
|
+
char: undefined,
|
|
307
|
+
code: undefined,
|
|
308
|
+
severity: "error",
|
|
309
|
+
message: `스타일(${scssLine}:${scssChar}): ${message}\n${err.message}`
|
|
310
|
+
}];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return [{
|
|
314
|
+
filePath: undefined,
|
|
315
|
+
line: undefined,
|
|
316
|
+
char: undefined,
|
|
317
|
+
code: undefined,
|
|
318
|
+
severity: "error",
|
|
319
|
+
message: err.stack
|
|
320
|
+
}];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private _createSdBuildPack(parsedTsconfig: ts.ParsedCommandLine): ISdBuildPack {
|
|
325
|
+
const compilerHost = this._createCacheCompilerHost(parsedTsconfig);
|
|
326
|
+
const { program, ngCompiler } = this._createProgram(parsedTsconfig, compilerHost);
|
|
327
|
+
|
|
328
|
+
this._builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(
|
|
329
|
+
program,
|
|
330
|
+
compilerHost,
|
|
331
|
+
this._builder
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
const affectedSourceFileSet: Set<ts.SourceFile> = new Set<ts.SourceFile>();
|
|
335
|
+
while (true) {
|
|
336
|
+
const result = this._builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
337
|
+
// this._logger.debug(sourceFile.fileName + " SYNTAX 로딩...");
|
|
338
|
+
if (ngCompiler?.ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
|
|
339
|
+
const orgFileName = sourceFile.fileName.slice(0, -15) + ".ts";
|
|
340
|
+
const orgSourceFile = this._builder!.getSourceFile(orgFileName);
|
|
341
|
+
if (orgSourceFile) {
|
|
342
|
+
affectedSourceFileSet.add(orgSourceFile);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return false;
|
|
349
|
+
});
|
|
350
|
+
if (!result) break;
|
|
351
|
+
|
|
352
|
+
// this._logger.debug((result.affected as ts.SourceFile).fileName + " SYNTAX 로딩");
|
|
353
|
+
affectedSourceFileSet.add(result.affected as ts.SourceFile);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
program,
|
|
358
|
+
ngCompiler,
|
|
359
|
+
builder: this._builder,
|
|
360
|
+
affectedSourceFiles: Array.from(affectedSourceFileSet.values())
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private _createProgram(parsedTsconfig: ts.ParsedCommandLine, compilerHost: ts.CompilerHost): { program: ts.Program; ngCompiler?: NgCompiler } {
|
|
365
|
+
if (this._isAngular) {
|
|
366
|
+
this._ngProgram = new NgtscProgram(
|
|
367
|
+
parsedTsconfig.fileNames,
|
|
368
|
+
parsedTsconfig.options,
|
|
369
|
+
compilerHost,
|
|
370
|
+
this._ngProgram
|
|
371
|
+
);
|
|
372
|
+
this._program = this._ngProgram.getTsProgram();
|
|
373
|
+
|
|
374
|
+
this._configProgramSourceFileVersions(this._program);
|
|
375
|
+
return {
|
|
376
|
+
program: this._program,
|
|
377
|
+
ngCompiler: this._ngProgram.compiler
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
this._program = ts.createProgram(
|
|
382
|
+
parsedTsconfig.fileNames,
|
|
383
|
+
parsedTsconfig.options,
|
|
384
|
+
compilerHost,
|
|
385
|
+
this._program
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
this._configProgramSourceFileVersions(this._program);
|
|
389
|
+
|
|
390
|
+
return { program: this._program };
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private _configProgramSourceFileVersions(program: ts.Program): void {
|
|
395
|
+
const baseGetSourceFiles = program.getSourceFiles;
|
|
396
|
+
program.getSourceFiles = function (...parameters) {
|
|
397
|
+
const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);
|
|
398
|
+
|
|
399
|
+
for (const file of files) {
|
|
400
|
+
if (file.version === undefined) {
|
|
401
|
+
file.version = createHash("sha256").update(file.text).digest("hex");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return files;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
private _createCacheCompilerHost(parsedTsconfig: ts.ParsedCommandLine): ts.CompilerHost {
|
|
410
|
+
if (!this._moduleResolutionCache) {
|
|
411
|
+
this._moduleResolutionCache = ts.createModuleResolutionCache(this._rootPath, (s) => s, parsedTsconfig.options);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const compilerHost = SdCliCacheCompilerHost.create(
|
|
415
|
+
parsedTsconfig,
|
|
416
|
+
this._moduleResolutionCache,
|
|
417
|
+
this._fileCache,
|
|
418
|
+
this._writeFileCache
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
if (this._isAngular) {
|
|
422
|
+
return SdCliNgCacheCompilerHost.wrap(compilerHost, this._fileCache);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
return compilerHost;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private _getNpmConfig(pkgPath: string): INpmConfig | undefined {
|
|
430
|
+
if (!this._npmConfigMap.has(pkgPath)) {
|
|
431
|
+
this._npmConfigMap.set(pkgPath, FsUtil.readJson(path.resolve(pkgPath, "package.json")));
|
|
432
|
+
}
|
|
433
|
+
return this._npmConfigMap.get(pkgPath);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
interface IFileCache {
|
|
438
|
+
exists?: boolean;
|
|
439
|
+
sourceFile?: ts.SourceFile;
|
|
440
|
+
content?: string;
|
|
441
|
+
styleContent?: string;
|
|
442
|
+
importerSet?: Set<string>;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
interface ISdBuildPack {
|
|
446
|
+
program: ts.Program;
|
|
447
|
+
ngCompiler?: NgCompiler;
|
|
448
|
+
builder: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
449
|
+
affectedSourceFiles: ts.SourceFile[];
|
|
450
|
+
}
|