@simplysm/sd-cli 7.0.65 → 7.0.75
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/SdCliBuildResultError.d.ts +5 -0
- package/dist/bin/sd-cli.d.ts +2 -0
- package/dist/bin/sd-cli.mjs +27 -6
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCordova.d.ts +16 -0
- package/dist/build-tool/SdCliCordova.mjs +176 -0
- package/dist/build-tool/SdCliIndexFileGenerator.d.ts +13 -0
- package/dist/{entry-points → build-tool}/SdCliIndexFileGenerator.mjs +4 -3
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +19 -2
- package/dist/builder/SdCliClientBuilder.d.ts +23 -0
- package/dist/builder/SdCliClientBuilder.mjs +69 -6
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliServerBuilder.d.ts +25 -0
- package/dist/builder/SdCliServerBuilder.mjs +19 -10
- package/dist/builder/SdCliTsLibBuilder.d.ts +34 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +84 -37
- package/dist/commons.d.ts +101 -0
- package/dist/entry-points/SdCliLocalUpdate.d.ts +13 -0
- package/dist/entry-points/SdCliNpm.d.ts +6 -0
- package/dist/entry-points/SdCliPrepare.d.ts +5 -0
- package/dist/entry-points/SdCliPrepare.mjs +2 -2
- package/dist/entry-points/SdCliWorkspace.d.ts +31 -0
- package/dist/entry-points/SdCliWorkspace.mjs +67 -51
- package/dist/index.d.ts +29 -0
- package/dist/index.mjs +5 -3
- package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +28 -0
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +486 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +23 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +187 -36
- package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +22 -0
- package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +10 -7
- package/dist/ng-tools/babel/SdCliBbUtil.d.ts +5 -0
- package/dist/ng-tools/babel/SdCliBbUtil.mjs +2 -2
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +42 -0
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +107 -76
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +44 -0
- package/dist/ng-tools/commons.d.ts +9 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +61 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +12 -12
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +8 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +5 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.mjs +28 -0
- package/dist/packages/SdCliPackage.d.ts +23 -0
- package/dist/packages/SdCliPackage.mjs +53 -7
- package/dist/utils/SdCliBuildResultUtil.d.ts +9 -0
- package/dist/utils/SdCliConfigUtil.d.ts +7 -0
- package/dist/utils/SdCliNpmConfigUtil.d.ts +7 -0
- package/package.json +11 -8
- package/src/bin/sd-cli.ts +26 -5
- package/src/build-tool/SdCliCordova.ts +224 -0
- package/src/{entry-points → build-tool}/SdCliIndexFileGenerator.ts +3 -2
- package/src/build-tool/SdCliPackageLinter.ts +18 -2
- package/src/builder/SdCliClientBuilder.ts +84 -5
- package/src/builder/SdCliServerBuilder.ts +20 -9
- package/src/builder/SdCliTsLibBuilder.ts +101 -45
- package/src/commons.ts +43 -0
- package/src/entry-points/SdCliPrepare.ts +1 -1
- package/src/entry-points/SdCliWorkspace.ts +71 -56
- package/src/index.ts +4 -2
- package/src/ng-tools/SdCliNgModuleGenerator.ts +643 -0
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +234 -38
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +10 -6
- package/src/ng-tools/babel/SdCliBbUtil.ts +1 -1
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +36 -22
- package/src/ng-tools/commons.ts +1 -1
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +12 -12
- package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -0
- package/src/packages/SdCliPackage.ts +56 -6
- package/tsconfig-build.json +1 -1
- package/tsconfig.json +3 -0
- package/dist/ng-tools/NgModuleGenerator.mjs +0 -278
- package/src/ng-tools/NgModuleGenerator.ts +0 -361
|
@@ -34,24 +34,55 @@ import { CssOptimizerPlugin } from "@angular-devkit/build-angular/src/webpack/pl
|
|
|
34
34
|
import browserslist from "browserslist";
|
|
35
35
|
import { augmentAppWithServiceWorker } from "@angular-devkit/build-angular/src/utils/service-worker";
|
|
36
36
|
import { StringUtil } from "@simplysm/sd-core-common";
|
|
37
|
+
import { SdCliNgModuleGenerator } from "../ng-tools/SdCliNgModuleGenerator";
|
|
38
|
+
import { SdCliCordova } from "../build-tool/SdCliCordova";
|
|
37
39
|
import LintResult = ESLint.LintResult;
|
|
38
40
|
|
|
39
41
|
export class SdCliClientBuilder extends EventEmitter {
|
|
40
|
-
private readonly _logger
|
|
42
|
+
private readonly _logger: Logger;
|
|
41
43
|
|
|
42
44
|
private readonly _tsconfigFilePath: string;
|
|
43
45
|
private readonly _parsedTsconfig: ts.ParsedCommandLine;
|
|
44
46
|
private readonly _npmConfigMap = new Map<string, INpmConfig>();
|
|
47
|
+
private readonly _ngModuleGenerator: SdCliNgModuleGenerator;
|
|
48
|
+
|
|
49
|
+
private readonly _cordova?: SdCliCordova;
|
|
45
50
|
|
|
46
51
|
public constructor(private readonly _rootPath: string,
|
|
47
52
|
private readonly _config: ISdCliClientPackageConfig,
|
|
48
53
|
private readonly _workspaceRootPath: string) {
|
|
49
54
|
super();
|
|
50
55
|
|
|
56
|
+
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
57
|
+
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, npmConfig.name]);
|
|
58
|
+
|
|
51
59
|
// tsconfig
|
|
52
60
|
this._tsconfigFilePath = path.resolve(this._rootPath, "tsconfig-build.json");
|
|
53
61
|
const tsconfig = FsUtil.readJson(this._tsconfigFilePath) as ITsconfig;
|
|
54
62
|
this._parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._rootPath, tsconfig.angularCompilerOptions);
|
|
63
|
+
|
|
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
|
+
], {
|
|
77
|
+
glob: "**/*Page.ts",
|
|
78
|
+
fileEndsWith: "Page",
|
|
79
|
+
rootClassName: "AppPage"
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// CORDOVA
|
|
83
|
+
if (this._config.cordova) {
|
|
84
|
+
this._cordova = new SdCliCordova(this._rootPath, this._config.cordova);
|
|
85
|
+
}
|
|
55
86
|
}
|
|
56
87
|
|
|
57
88
|
public override on(event: "change", listener: () => void): this;
|
|
@@ -64,18 +95,47 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
64
95
|
// DIST 비우기
|
|
65
96
|
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
66
97
|
|
|
98
|
+
// NgModule 생성
|
|
99
|
+
await this._ngModuleGenerator.runAsync();
|
|
100
|
+
|
|
101
|
+
// CORDOVA
|
|
102
|
+
if (this._cordova) {
|
|
103
|
+
this._logger.debug("CORDOVA 구성...");
|
|
104
|
+
await this._cordova.initializeAsync();
|
|
105
|
+
}
|
|
106
|
+
|
|
67
107
|
// 빌드 준비
|
|
68
108
|
const webpackConfig = this._getWebpackConfig(true);
|
|
69
109
|
const compiler = webpack(webpackConfig);
|
|
70
110
|
return await new Promise<NextHandleFunction[]>((resolve, reject) => {
|
|
71
|
-
compiler.hooks.
|
|
111
|
+
compiler.hooks.invalid.tap(this.constructor.name, (fileName) => {
|
|
112
|
+
if (fileName != null) {
|
|
113
|
+
this._logger.debug("파일변경 감지", fileName);
|
|
114
|
+
// NgModule 캐시 삭제
|
|
115
|
+
this._ngModuleGenerator.removeCaches([path.resolve(fileName)]);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
compiler.hooks.watchRun.tapAsync(this.constructor.name, async (args, callback) => {
|
|
72
120
|
this.emit("change");
|
|
121
|
+
|
|
122
|
+
// NgModule 생성
|
|
123
|
+
await this._ngModuleGenerator.runAsync();
|
|
124
|
+
|
|
73
125
|
callback();
|
|
74
126
|
|
|
75
127
|
this._logger.debug("Webpack 빌드 수행...");
|
|
76
128
|
});
|
|
77
129
|
|
|
78
130
|
compiler.hooks.failed.tap(this.constructor.name, (err) => {
|
|
131
|
+
this.emit("complete", [{
|
|
132
|
+
filePath: undefined,
|
|
133
|
+
line: undefined,
|
|
134
|
+
char: undefined,
|
|
135
|
+
code: undefined,
|
|
136
|
+
severity: "error",
|
|
137
|
+
message: err.stack
|
|
138
|
+
}]);
|
|
79
139
|
reject(err);
|
|
80
140
|
return;
|
|
81
141
|
});
|
|
@@ -83,7 +143,6 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
83
143
|
compiler.hooks.done.tap(this.constructor.name, async (stats) => {
|
|
84
144
|
// 결과 반환
|
|
85
145
|
const results = SdCliBuildResultUtil.convertFromWebpackStats(stats);
|
|
86
|
-
this.emit("complete", results);
|
|
87
146
|
|
|
88
147
|
// .config.json 파일 쓰기
|
|
89
148
|
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
@@ -97,6 +156,8 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
97
156
|
// 마무리
|
|
98
157
|
this._logger.debug("Webpack 빌드 완료");
|
|
99
158
|
resolve([devMiddleware, hotMiddleware]);
|
|
159
|
+
|
|
160
|
+
this.emit("complete", results);
|
|
100
161
|
});
|
|
101
162
|
|
|
102
163
|
const devMiddleware = wdm(compiler, {
|
|
@@ -116,6 +177,9 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
116
177
|
// DIST 비우기
|
|
117
178
|
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
118
179
|
|
|
180
|
+
// NgModule 생성
|
|
181
|
+
await this._ngModuleGenerator.runAsync();
|
|
182
|
+
|
|
119
183
|
// 빌드
|
|
120
184
|
this._logger.debug("Webpack 빌드 수행...");
|
|
121
185
|
const webpackConfig = this._getWebpackConfig(false);
|
|
@@ -148,6 +212,15 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
148
212
|
);
|
|
149
213
|
}
|
|
150
214
|
|
|
215
|
+
// CORDOVA
|
|
216
|
+
if (this._cordova) {
|
|
217
|
+
this._logger.debug("CORDOVA 구성...");
|
|
218
|
+
await this._cordova.initializeAsync();
|
|
219
|
+
|
|
220
|
+
this._logger.debug("CORDOVA 빌드...");
|
|
221
|
+
await this._cordova.buildAsync(this._parsedTsconfig.options.outDir!);
|
|
222
|
+
}
|
|
223
|
+
|
|
151
224
|
// 마무리
|
|
152
225
|
this._logger.debug("Webpack 빌드 완료");
|
|
153
226
|
return buildResults;
|
|
@@ -176,7 +249,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
176
249
|
const cacheBasePath = path.resolve(this._rootPath, ".cache");
|
|
177
250
|
const cachePath = path.resolve(cacheBasePath, pkgVersion);
|
|
178
251
|
|
|
179
|
-
const distPath = this._parsedTsconfig.options.outDir;
|
|
252
|
+
const distPath = (this._cordova && !watch) ? path.resolve(this._cordova.cordovaPath, "www") : this._parsedTsconfig.options.outDir;
|
|
180
253
|
|
|
181
254
|
const sassImplementation = new SassWorkerImplementation();
|
|
182
255
|
|
|
@@ -250,6 +323,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
250
323
|
.update(watch.toString())
|
|
251
324
|
.digest("hex")
|
|
252
325
|
},
|
|
326
|
+
// cache: { type: "memory", maxGenerations: 1 },
|
|
253
327
|
...watch ? {
|
|
254
328
|
snapshot: {
|
|
255
329
|
immutablePaths: internalModuleCachePaths,
|
|
@@ -462,7 +536,12 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
462
536
|
].map((i) => PathUtil.posix(this._rootPath, i))
|
|
463
537
|
},
|
|
464
538
|
priority: 0
|
|
465
|
-
}))
|
|
539
|
+
})),
|
|
540
|
+
...this._cordova ? this._cordova.platforms.map((platform) => ({
|
|
541
|
+
context: this._cordova!.cordovaPath,
|
|
542
|
+
to: `cordova-${platform}`,
|
|
543
|
+
from: `platforms/${platform}/platform_www`
|
|
544
|
+
})) : []
|
|
466
545
|
]
|
|
467
546
|
}),
|
|
468
547
|
...watch ? [
|
|
@@ -13,8 +13,8 @@ import { ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
|
|
|
13
13
|
import ESLintWebpackPlugin from "eslint-webpack-plugin";
|
|
14
14
|
import CopyWebpackPlugin from "copy-webpack-plugin";
|
|
15
15
|
import { LicenseWebpackPlugin } from "license-webpack-plugin";
|
|
16
|
-
import { createHash } from "crypto";
|
|
17
16
|
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
18
|
import LintResult = ESLint.LintResult;
|
|
19
19
|
|
|
20
20
|
export class SdCliServerBuilder extends EventEmitter {
|
|
@@ -47,7 +47,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
47
47
|
|
|
48
48
|
// 빌드 준비
|
|
49
49
|
const extModules = this._getExternalModules();
|
|
50
|
-
const webpackConfig = this._getWebpackConfig(true, extModules
|
|
50
|
+
const webpackConfig = this._getWebpackConfig(true, extModules);
|
|
51
51
|
const compiler = webpack(webpackConfig);
|
|
52
52
|
await new Promise<void>((resolve, reject) => {
|
|
53
53
|
compiler.hooks.watchRun.tapAsync(this.constructor.name, (args, callback) => {
|
|
@@ -81,7 +81,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
81
81
|
// 빌드
|
|
82
82
|
this._logger.debug("Webpack 빌드 수행...");
|
|
83
83
|
const extModules = this._getExternalModules();
|
|
84
|
-
const webpackConfig = this._getWebpackConfig(false, extModules
|
|
84
|
+
const webpackConfig = this._getWebpackConfig(false, extModules);
|
|
85
85
|
const compiler = webpack(webpackConfig);
|
|
86
86
|
const buildResults = await new Promise<ISdCliPackageBuildResult[]>((resolve, reject) => {
|
|
87
87
|
compiler.run((err, stats) => {
|
|
@@ -130,6 +130,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
130
130
|
{
|
|
131
131
|
"name": npmConfig.name.replace(/@/g, "").replace(/\//g, "-"),
|
|
132
132
|
"script": path.basename(path.resolve(this._parsedTsconfig.options.outDir!, "main.mjs")),
|
|
133
|
+
"node_args": "--experimental-specifier-resolution=node --experimental-import-meta-resolve",
|
|
133
134
|
"watch": true,
|
|
134
135
|
"watch_delay": 2000,
|
|
135
136
|
"ignore_watch": [
|
|
@@ -211,7 +212,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
211
212
|
].map((p) => path.dirname(p));
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
private _getWebpackConfig(watch: boolean,
|
|
215
|
+
private _getWebpackConfig(watch: boolean, extModules: { name: string; exists: boolean }[]): webpack.Configuration {
|
|
215
216
|
const workspaceNpmConfig = this._getNpmConfig(this._workspaceRootPath)!;
|
|
216
217
|
const workspaceName = workspaceNpmConfig.name;
|
|
217
218
|
|
|
@@ -256,17 +257,18 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
256
257
|
assetModuleFilename: "res/[name][ext][query]",
|
|
257
258
|
library: {
|
|
258
259
|
type: "module"
|
|
259
|
-
}
|
|
260
|
+
},
|
|
261
|
+
module: true
|
|
260
262
|
},
|
|
261
|
-
watch: false,
|
|
262
|
-
watchOptions: { poll: undefined, ignored: undefined },
|
|
263
|
-
performance: { hints: false },
|
|
264
263
|
experiments: {
|
|
265
264
|
outputModule: true
|
|
266
265
|
},
|
|
266
|
+
watch: false,
|
|
267
|
+
watchOptions: { poll: undefined, ignored: undefined },
|
|
268
|
+
performance: { hints: false },
|
|
267
269
|
infrastructureLogging: { level: "error" },
|
|
268
270
|
stats: "errors-warnings",
|
|
269
|
-
externals:
|
|
271
|
+
externals: extModules.toObject((item) => item.name, (item) => "node-commonjs " + item.name),
|
|
270
272
|
cache: {
|
|
271
273
|
type: "filesystem",
|
|
272
274
|
profile: watch ? undefined : false,
|
|
@@ -281,6 +283,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
281
283
|
.update(watch.toString())
|
|
282
284
|
.digest("hex")
|
|
283
285
|
},
|
|
286
|
+
// cache: { type: "memory", maxGenerations: 1 },
|
|
284
287
|
...watch ? {
|
|
285
288
|
snapshot: {
|
|
286
289
|
immutablePaths: internalModuleCachePaths,
|
|
@@ -457,6 +460,10 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
457
460
|
results.push({ name: moduleName, exists: true });
|
|
458
461
|
}
|
|
459
462
|
|
|
463
|
+
if (this._config.externalNodeModules?.includes(moduleName)) {
|
|
464
|
+
results.push({ name: moduleName, exists: true });
|
|
465
|
+
}
|
|
466
|
+
|
|
460
467
|
fn(modulePath);
|
|
461
468
|
}
|
|
462
469
|
|
|
@@ -474,6 +481,10 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
474
481
|
results.push({ name: optModuleName, exists: true });
|
|
475
482
|
}
|
|
476
483
|
|
|
484
|
+
if (this._config.externalNodeModules?.includes(optModuleName)) {
|
|
485
|
+
results.push({ name: optModuleName, exists: true });
|
|
486
|
+
}
|
|
487
|
+
|
|
477
488
|
fn(optModulePath);
|
|
478
489
|
}
|
|
479
490
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INpmConfig, ISdCliPackageBuildResult } from "../commons";
|
|
1
|
+
import { INpmConfig, ISdCliLibPackageConfig, ISdCliPackageBuildResult } from "../commons";
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
@@ -12,10 +12,11 @@ import { SdCliCacheCompilerHost } from "../build-tool/SdCliCacheCompilerHost";
|
|
|
12
12
|
import { SdCliNgCacheCompilerHost } from "../build-tool/SdCliNgCacheCompilerHost";
|
|
13
13
|
import { NgCompiler } from "@angular/compiler-cli/src/ngtsc/core";
|
|
14
14
|
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
15
|
-
import {
|
|
15
|
+
import { SdCliNgModuleGenerator } from "../ng-tools/SdCliNgModuleGenerator";
|
|
16
|
+
import { SdCliIndexFileGenerator } from "../build-tool/SdCliIndexFileGenerator";
|
|
16
17
|
|
|
17
18
|
export class SdCliTsLibBuilder extends EventEmitter {
|
|
18
|
-
private readonly _logger
|
|
19
|
+
private readonly _logger: Logger;
|
|
19
20
|
|
|
20
21
|
private _moduleResolutionCache?: ts.ModuleResolutionCache;
|
|
21
22
|
|
|
@@ -24,31 +25,63 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
24
25
|
private readonly _fileCache = new Map<string, IFileCache>();
|
|
25
26
|
private readonly _writeFileCache = new Map<string, string>();
|
|
26
27
|
|
|
28
|
+
private readonly _indexFileGenerator?: SdCliIndexFileGenerator;
|
|
29
|
+
|
|
27
30
|
private _program?: ts.Program;
|
|
28
31
|
private _ngProgram?: NgtscProgram;
|
|
29
32
|
private _builder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
30
|
-
private _ngModuleGenerator?:
|
|
33
|
+
private readonly _ngModuleGenerator?: SdCliNgModuleGenerator;
|
|
31
34
|
|
|
32
35
|
private readonly _tsconfigFilePath: string;
|
|
33
36
|
private readonly _parsedTsconfig: ts.ParsedCommandLine;
|
|
34
|
-
private readonly
|
|
37
|
+
private readonly _npmConfigMap = new Map<string, INpmConfig>();
|
|
35
38
|
|
|
36
39
|
private readonly _isAngular: boolean;
|
|
37
40
|
|
|
38
|
-
public constructor(private readonly _rootPath: string
|
|
41
|
+
public constructor(private readonly _rootPath: string,
|
|
42
|
+
private readonly _config: ISdCliLibPackageConfig,
|
|
43
|
+
private readonly _workspaceRootPath: string) {
|
|
39
44
|
super();
|
|
45
|
+
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
46
|
+
|
|
47
|
+
// linter
|
|
40
48
|
this._linter = new SdCliPackageLinter(this._rootPath);
|
|
41
49
|
|
|
50
|
+
// logger
|
|
51
|
+
this._logger = Logger.get(["simplysm", "sd-cli", this.constructor.name, npmConfig.name]);
|
|
52
|
+
|
|
53
|
+
// isAngular
|
|
54
|
+
this._isAngular = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults.includes("@angular/core");
|
|
55
|
+
|
|
42
56
|
// tsconfig
|
|
43
57
|
this._tsconfigFilePath = path.resolve(this._rootPath, "tsconfig-build.json");
|
|
44
58
|
const tsconfig = FsUtil.readJson(this._tsconfigFilePath);
|
|
45
|
-
this._parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._rootPath);
|
|
59
|
+
this._parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._rootPath, this._isAngular ? tsconfig.angularCompilerOptions : undefined);
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
if (this._isAngular) {
|
|
62
|
+
// NgModule 생성기 초기화
|
|
63
|
+
this._ngModuleGenerator = new SdCliNgModuleGenerator(this._rootPath, [
|
|
64
|
+
"controls",
|
|
65
|
+
"directives",
|
|
66
|
+
"guards",
|
|
67
|
+
"modals",
|
|
68
|
+
"providers",
|
|
69
|
+
"app",
|
|
70
|
+
"pages",
|
|
71
|
+
"print-templates",
|
|
72
|
+
"toasts",
|
|
73
|
+
"AppPage"
|
|
74
|
+
], {
|
|
75
|
+
glob: "**/*Page.ts",
|
|
76
|
+
fileEndsWith: "Page",
|
|
77
|
+
rootClassName: "AppPage"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
49
80
|
|
|
50
|
-
//
|
|
51
|
-
|
|
81
|
+
// index 생성기 초기화
|
|
82
|
+
if (this._config.autoIndex) {
|
|
83
|
+
this._indexFileGenerator = new SdCliIndexFileGenerator(this._rootPath, this._config.autoIndex);
|
|
84
|
+
}
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
public override on(event: "change", listener: () => void): this;
|
|
@@ -60,32 +93,24 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
60
93
|
public async watchAsync(): Promise<void> {
|
|
61
94
|
this.emit("change");
|
|
62
95
|
|
|
63
|
-
|
|
96
|
+
this._logger.debug("dist 폴더 삭제...");
|
|
64
97
|
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
65
98
|
|
|
66
|
-
if (this.
|
|
67
|
-
|
|
68
|
-
this._ngModuleGenerator = new NgModuleGenerator(this._rootPath, [
|
|
69
|
-
"controls",
|
|
70
|
-
"directives",
|
|
71
|
-
"guards",
|
|
72
|
-
"modals",
|
|
73
|
-
"providers",
|
|
74
|
-
"pages",
|
|
75
|
-
"print-templates",
|
|
76
|
-
"toasts"
|
|
77
|
-
]);
|
|
78
|
-
|
|
79
|
-
// NgModule 타겟 디렉토리 삭제
|
|
80
|
-
await this._ngModuleGenerator.clearModulesAsync();
|
|
81
|
-
|
|
82
|
-
// NgModule 생성
|
|
99
|
+
if (this._ngModuleGenerator) {
|
|
100
|
+
this._logger.debug("NgModule 생성...");
|
|
83
101
|
await this._ngModuleGenerator.runAsync();
|
|
84
102
|
}
|
|
85
103
|
|
|
86
|
-
|
|
104
|
+
if (this._indexFileGenerator) {
|
|
105
|
+
this._logger.debug("index.js 생성 및 index.js용 변경감지 시작...");
|
|
106
|
+
await this._indexFileGenerator.runAsync();
|
|
107
|
+
await this._indexFileGenerator.watchAsync();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this._logger.debug("프로그램 로딩...");
|
|
87
111
|
const buildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
88
112
|
|
|
113
|
+
this._logger.debug("변경감지 구성...");
|
|
89
114
|
const relatedPaths = await this.getAllRelatedPathsAsync();
|
|
90
115
|
const watcher = SdFsWatcher.watch(relatedPaths);
|
|
91
116
|
watcher.onChange({}, async (changeInfos) => {
|
|
@@ -95,24 +120,26 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
95
120
|
this._logger.debug("파일 변경 감지", changeInfos);
|
|
96
121
|
this.emit("change");
|
|
97
122
|
|
|
98
|
-
|
|
123
|
+
this._logger.debug("변경된 파일의 캐쉬 삭제...");
|
|
99
124
|
for (const changeFilePath of changeFilePaths) {
|
|
100
125
|
this._fileCache.delete(PathUtil.posix(changeFilePath));
|
|
101
126
|
}
|
|
102
127
|
|
|
103
|
-
if (this.
|
|
104
|
-
|
|
105
|
-
this._ngModuleGenerator
|
|
106
|
-
await this._ngModuleGenerator
|
|
128
|
+
if (this._ngModuleGenerator) {
|
|
129
|
+
this._logger.debug("NgModule 생성...");
|
|
130
|
+
this._ngModuleGenerator.removeCaches(changeFilePaths);
|
|
131
|
+
await this._ngModuleGenerator.runAsync();
|
|
107
132
|
}
|
|
108
133
|
|
|
109
134
|
const watchBuildResults: ISdCliPackageBuildResult[] = [];
|
|
110
135
|
|
|
111
|
-
|
|
136
|
+
this._logger.debug("프로그램 로딩...");
|
|
112
137
|
const watchBuildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
138
|
+
|
|
139
|
+
this._logger.debug("빌드...");
|
|
113
140
|
watchBuildResults.push(...await this._runBuilderAsync(watchBuildPack.builder, watchBuildPack.ngCompiler));
|
|
114
141
|
|
|
115
|
-
|
|
142
|
+
this._logger.debug("린트...");
|
|
116
143
|
const lintFilePaths = [
|
|
117
144
|
...watchBuildPack.affectedSourceFiles.map((item) => item.fileName),
|
|
118
145
|
...changeInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path)
|
|
@@ -121,32 +148,43 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
121
148
|
watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths, watchBuildPack.program));
|
|
122
149
|
}
|
|
123
150
|
|
|
151
|
+
this._logger.debug("변경감지 대상목록 재구성...");
|
|
124
152
|
const watchRelatedPaths = await this.getAllRelatedPathsAsync();
|
|
125
153
|
watcher.add(watchRelatedPaths);
|
|
126
154
|
|
|
127
155
|
this.emit("complete", watchBuildResults);
|
|
128
156
|
});
|
|
129
157
|
|
|
130
|
-
|
|
158
|
+
this._logger.debug("빌드...");
|
|
131
159
|
const buildResults = await this._runBuilderAsync(buildPack.builder, buildPack.ngCompiler);
|
|
132
160
|
|
|
133
|
-
|
|
161
|
+
this._logger.debug("린트...");
|
|
134
162
|
buildResults.push(...await this._linter.lintAsync(relatedPaths, buildPack.program));
|
|
135
163
|
|
|
136
164
|
this.emit("complete", buildResults);
|
|
137
165
|
}
|
|
138
166
|
|
|
139
167
|
public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
|
|
140
|
-
|
|
168
|
+
this._logger.debug("dist 폴더 삭제...");
|
|
141
169
|
await FsUtil.removeAsync(this._parsedTsconfig.options.outDir!);
|
|
142
170
|
|
|
143
|
-
|
|
171
|
+
if (this._ngModuleGenerator) {
|
|
172
|
+
this._logger.debug("NgModule 생성...");
|
|
173
|
+
await this._ngModuleGenerator.runAsync();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (this._indexFileGenerator) {
|
|
177
|
+
this._logger.debug("index.js 생성...");
|
|
178
|
+
await this._indexFileGenerator.runAsync();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this._logger.debug("프로그램 로딩...");
|
|
144
182
|
const buildPack = this._createSdBuildPack(this._parsedTsconfig);
|
|
145
183
|
|
|
146
|
-
|
|
184
|
+
this._logger.debug("빌드...");
|
|
147
185
|
const buildResults = await this._runBuilderAsync(buildPack.builder, buildPack.ngCompiler);
|
|
148
186
|
|
|
149
|
-
|
|
187
|
+
this._logger.debug("린트...");
|
|
150
188
|
const relatedPaths = await this.getAllRelatedPathsAsync();
|
|
151
189
|
buildResults.push(...await this._linter.lintAsync(relatedPaths, buildPack.program));
|
|
152
190
|
|
|
@@ -154,7 +192,16 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
154
192
|
}
|
|
155
193
|
|
|
156
194
|
private async getAllRelatedPathsAsync(): Promise<string[]> {
|
|
157
|
-
const
|
|
195
|
+
const workspaceNpmConfig = this._getNpmConfig(this._workspaceRootPath)!;
|
|
196
|
+
const workspaceName = workspaceNpmConfig.name;
|
|
197
|
+
|
|
198
|
+
const fileCachePaths = Array.from(this._fileCache.keys())
|
|
199
|
+
.filter((filePath) => {
|
|
200
|
+
const workspaceRegex = new RegExp(`node_modules[\\\\/]@${workspaceName}[\\\\/]`);
|
|
201
|
+
return !filePath.includes("node_modules")
|
|
202
|
+
|| (/node_modules[\\/]@simplysm[\\/]/).test(filePath)
|
|
203
|
+
|| workspaceRegex.test(filePath);
|
|
204
|
+
});
|
|
158
205
|
const mySourceGlobPath = path.resolve(this._rootPath, "**", "+(*.js|*.cjs|*.mjs|*.ts)");
|
|
159
206
|
const mySourceFilePaths = await FsUtil.globAsync(mySourceGlobPath, {
|
|
160
207
|
ignore: [
|
|
@@ -249,7 +296,7 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
249
296
|
char: undefined,
|
|
250
297
|
code: undefined,
|
|
251
298
|
severity: "error",
|
|
252
|
-
message: err.
|
|
299
|
+
message: err.stack
|
|
253
300
|
}];
|
|
254
301
|
}
|
|
255
302
|
}
|
|
@@ -267,6 +314,7 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
267
314
|
const affectedSourceFileSet: Set<ts.SourceFile> = new Set<ts.SourceFile>();
|
|
268
315
|
while (true) {
|
|
269
316
|
const result = this._builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
317
|
+
// this._logger.debug(sourceFile.fileName + " SYNTAX 로딩...");
|
|
270
318
|
if (ngCompiler?.ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
|
|
271
319
|
const orgFileName = sourceFile.fileName.slice(0, -15) + ".ts";
|
|
272
320
|
const orgSourceFile = this._builder!.getSourceFile(orgFileName);
|
|
@@ -281,6 +329,7 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
281
329
|
});
|
|
282
330
|
if (!result) break;
|
|
283
331
|
|
|
332
|
+
// this._logger.debug((result.affected as ts.SourceFile).fileName + " SYNTAX 로딩");
|
|
284
333
|
affectedSourceFileSet.add(result.affected as ts.SourceFile);
|
|
285
334
|
}
|
|
286
335
|
|
|
@@ -356,6 +405,13 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
356
405
|
return compilerHost;
|
|
357
406
|
}
|
|
358
407
|
}
|
|
408
|
+
|
|
409
|
+
private _getNpmConfig(pkgPath: string): INpmConfig | undefined {
|
|
410
|
+
if (!this._npmConfigMap.has(pkgPath)) {
|
|
411
|
+
this._npmConfigMap.set(pkgPath, FsUtil.readJson(path.resolve(pkgPath, "package.json")));
|
|
412
|
+
}
|
|
413
|
+
return this._npmConfigMap.get(pkgPath);
|
|
414
|
+
}
|
|
359
415
|
}
|
|
360
416
|
|
|
361
417
|
interface IFileCache {
|
package/src/commons.ts
CHANGED
|
@@ -57,11 +57,54 @@ export interface ISdCliServerPackageConfig {
|
|
|
57
57
|
configs?: Record<string, any>;
|
|
58
58
|
pm2?: Record<string, any> | boolean;
|
|
59
59
|
iis?: { serverExeFilePath?: string } | boolean;
|
|
60
|
+
externalNodeModules?: string[];
|
|
61
|
+
publish?: TSdCliPublishConfig;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
export interface ISdCliClientPackageConfig {
|
|
63
65
|
type: "client";
|
|
66
|
+
cordova?: ISdCliClientPackageCordovaConfig;
|
|
64
67
|
server: string;
|
|
65
68
|
env?: Record<string, string>;
|
|
66
69
|
configs?: Record<string, any>;
|
|
70
|
+
publish?: TSdCliPublishConfig;
|
|
67
71
|
}
|
|
72
|
+
|
|
73
|
+
export type TSdCliPublishConfig = ISdCliFtpPublishConfig | ISdCliLocalDirectoryPublishConfig;
|
|
74
|
+
|
|
75
|
+
export interface ISdCliFtpPublishConfig {
|
|
76
|
+
type: "ftp" | "ftps" | "sftp";
|
|
77
|
+
host: string;
|
|
78
|
+
port?: number;
|
|
79
|
+
path: string;
|
|
80
|
+
user: string;
|
|
81
|
+
pass: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ISdCliLocalDirectoryPublishConfig {
|
|
85
|
+
type: "local-directory";
|
|
86
|
+
path: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ISdCliClientPackageCordovaConfig {
|
|
90
|
+
platforms: TSdCliCordovaPlatform[];
|
|
91
|
+
appId: string;
|
|
92
|
+
appName: string;
|
|
93
|
+
plugins?: string[];
|
|
94
|
+
icon?: string;
|
|
95
|
+
buildOption?: {
|
|
96
|
+
debug?: boolean;
|
|
97
|
+
bundle?: boolean;
|
|
98
|
+
sign?: {
|
|
99
|
+
android?: {
|
|
100
|
+
keystore: string;
|
|
101
|
+
storePassword: string;
|
|
102
|
+
alias: string;
|
|
103
|
+
password: string;
|
|
104
|
+
keystoreType: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type TSdCliCordovaPlatform = "browser" | "ios" | "android" | "windows";
|