@simplysm/sd-cli 10.0.66 → 11.0.3
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 +15 -14
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdTsIncrementalBuilder.d.ts +2 -0
- package/dist/build-tools/SdTsIncrementalBuilder.js +60 -9
- package/dist/build-tools/SdTsIncrementalBuilder.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.d.ts +6 -7
- package/dist/builders/SdCliClientBuilder.js +281 -248
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +4 -3
- package/dist/builders/SdCliServerBuilder.js +3 -2
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +4 -4
- package/dist/builders/SdCliTsLibBuilder.js +9 -61
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +4 -5
- package/dist/entry/SdCliProject.js +13 -12
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +0 -19
- package/dist/sd-cli.js.map +1 -1
- package/package.json +14 -18
- package/src/build-cluster.ts +15 -14
- package/src/build-tools/SdTsIncrementalBuilder.ts +92 -10
- package/src/builders/SdCliClientBuilder.ts +310 -289
- package/src/builders/SdCliServerBuilder.ts +12 -7
- package/src/builders/SdCliTsLibBuilder.ts +11 -80
- package/src/commons.ts +5 -5
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliLocalUpdate.ts +3 -3
- package/src/entry/SdCliProject.ts +20 -18
- package/src/index.ts +0 -10
- package/src/sd-cli.ts +0 -23
- 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/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
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/sd-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.3",
|
|
4
4
|
"description": "심플리즘 패키지 - CLI",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/kslhunter/
|
|
8
|
+
"url": "https://github.com/kslhunter/simplysm11.git",
|
|
9
9
|
"directory": "packages/sd-cli"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
@@ -17,33 +17,29 @@
|
|
|
17
17
|
"node": "^16"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@angular-devkit/build-angular": "^16.2.5",
|
|
21
|
+
"@angular/common": "^16.2.8",
|
|
22
|
+
"@angular/compiler": "^16.2.8",
|
|
23
|
+
"@angular/compiler-cli": "^16.2.8",
|
|
24
|
+
"@angular/core": "^16.2.8",
|
|
20
25
|
"@electron/rebuild": "^3.3.0",
|
|
21
|
-
"@
|
|
22
|
-
"@simplysm/sd-core-
|
|
23
|
-
"@simplysm/sd-
|
|
24
|
-
"@simplysm/sd-
|
|
25
|
-
"@simplysm/sd-storage": "10.0.66",
|
|
26
|
-
"@swc/core": "^1.3.91",
|
|
27
|
-
"@vite-pwa/assets-generator": "^0.0.10",
|
|
28
|
-
"@vitejs/plugin-react-swc": "^3.4.0",
|
|
26
|
+
"@simplysm/sd-core-common": "11.0.3",
|
|
27
|
+
"@simplysm/sd-core-node": "11.0.3",
|
|
28
|
+
"@simplysm/sd-service-server": "11.0.3",
|
|
29
|
+
"@simplysm/sd-storage": "11.0.3",
|
|
29
30
|
"electron": "^26.2.4",
|
|
30
31
|
"electron-builder": "^24.7.0",
|
|
31
32
|
"esbuild": "^0.19.4",
|
|
32
33
|
"esbuild-plugin-tsc": "^0.4.0",
|
|
33
34
|
"eslint": "^8.50.0",
|
|
34
|
-
"less": "^4.2.0",
|
|
35
|
-
"lib-esm": "^0.4.1",
|
|
36
35
|
"node-stdlib-browser": "^1.2.0",
|
|
36
|
+
"rxjs": "^7.8.1",
|
|
37
37
|
"semver": "^7.5.4",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"vite-plugin-pwa": "^0.16.5",
|
|
41
|
-
"vite-tsconfig-paths": "^4.2.1",
|
|
42
|
-
"yargs": "^17.7.2"
|
|
38
|
+
"yargs": "^17.7.2",
|
|
39
|
+
"zone.js": "~0.13.0"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
42
|
"@types/eslint": "^8.44.3",
|
|
46
|
-
"@types/less": "^3.0.4",
|
|
47
43
|
"@types/yargs": "^17.0.26"
|
|
48
44
|
},
|
|
49
45
|
"peerDependencies": {
|
package/src/build-cluster.ts
CHANGED
|
@@ -48,10 +48,11 @@ if (cluster.isPrimary) {
|
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
const message = JSON.parse(process.env["SD_CLUSTER_MESSAGE"]!) as ISdCliBuildClusterReqMessage;
|
|
51
|
+
const pkgConf = message.projConf.packages[path.basename(message.pkgPath)]!;
|
|
51
52
|
|
|
52
53
|
if (message.cmd === "watch") {
|
|
53
54
|
// [library] javascript
|
|
54
|
-
if (
|
|
55
|
+
if (pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
55
56
|
if (message.withLint) {
|
|
56
57
|
await new SdCliJsLibLinter(message.pkgPath)
|
|
57
58
|
.on("change", () => {
|
|
@@ -75,8 +76,8 @@ else {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
// [library] typescript
|
|
78
|
-
else if (
|
|
79
|
-
await new SdCliTsLibBuilder(message.
|
|
79
|
+
else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
80
|
+
await new SdCliTsLibBuilder(message.projConf, message.pkgPath, message.withLint)
|
|
80
81
|
.on("change", () => {
|
|
81
82
|
sendMessage({
|
|
82
83
|
type: "change",
|
|
@@ -97,8 +98,8 @@ else {
|
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
// [server]
|
|
100
|
-
else if (
|
|
101
|
-
await new SdCliServerBuilder(message.
|
|
101
|
+
else if (pkgConf.type === "server") {
|
|
102
|
+
await new SdCliServerBuilder(message.projConf, message.pkgPath, message.withLint)
|
|
102
103
|
.on("change", () => {
|
|
103
104
|
sendMessage({
|
|
104
105
|
type: "change",
|
|
@@ -119,8 +120,8 @@ else {
|
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
// [client]
|
|
122
|
-
else if (
|
|
123
|
-
await new SdCliClientBuilder(message.
|
|
123
|
+
else if (pkgConf.type === "client") {
|
|
124
|
+
await new SdCliClientBuilder(message.projConf, message.pkgPath)
|
|
124
125
|
.on("change", () => {
|
|
125
126
|
sendMessage({
|
|
126
127
|
type: "change",
|
|
@@ -146,7 +147,7 @@ else {
|
|
|
146
147
|
}
|
|
147
148
|
else { // build
|
|
148
149
|
// [library] javascript
|
|
149
|
-
if (
|
|
150
|
+
if (pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
150
151
|
if (message.withLint) {
|
|
151
152
|
const result = await new SdCliJsLibLinter(message.pkgPath).buildAsync();
|
|
152
153
|
sendMessage({
|
|
@@ -164,8 +165,8 @@ else {
|
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
// [library] typescript
|
|
167
|
-
else if (
|
|
168
|
-
const result = await new SdCliTsLibBuilder(message.
|
|
168
|
+
else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
169
|
+
const result = await new SdCliTsLibBuilder(message.projConf, message.pkgPath, message.withLint).buildAsync();
|
|
169
170
|
sendMessage({
|
|
170
171
|
type: "complete",
|
|
171
172
|
result,
|
|
@@ -173,8 +174,8 @@ else {
|
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
// [server]
|
|
176
|
-
else if (
|
|
177
|
-
const result = await new SdCliServerBuilder(message.
|
|
177
|
+
else if (pkgConf.type === "server") {
|
|
178
|
+
const result = await new SdCliServerBuilder(message.projConf, message.pkgPath, message.withLint).buildAsync();
|
|
178
179
|
sendMessage({
|
|
179
180
|
type: "complete",
|
|
180
181
|
result,
|
|
@@ -182,8 +183,8 @@ else {
|
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
// [client]
|
|
185
|
-
else if (
|
|
186
|
-
const result = await new SdCliClientBuilder(message.
|
|
186
|
+
else if (pkgConf.type === "client") {
|
|
187
|
+
const result = await new SdCliClientBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
187
188
|
sendMessage({
|
|
188
189
|
type: "complete",
|
|
189
190
|
result,
|
|
@@ -3,6 +3,8 @@ import ts from "typescript";
|
|
|
3
3
|
import {SdCliBuildResultUtil} from "../utils/SdCliBuildResultUtil";
|
|
4
4
|
import {FsUtil, Logger, PathUtil} from "@simplysm/sd-core-node";
|
|
5
5
|
import {ISdCliPackageBuildResult} from "../commons";
|
|
6
|
+
import {NgtscProgram} from "@angular/compiler-cli";
|
|
7
|
+
import {createHash} from "crypto";
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
interface IOptTransform<T> {
|
|
@@ -12,6 +14,9 @@ interface IOptTransform<T> {
|
|
|
12
14
|
|
|
13
15
|
export class SdTsIncrementalBuilder {
|
|
14
16
|
public builderProgram?: ts.SemanticDiagnosticsBuilderProgram;
|
|
17
|
+
|
|
18
|
+
private _program?: ts.Program;
|
|
19
|
+
private _ngProgram?: NgtscProgram;
|
|
15
20
|
private readonly _writeFileCache = new Map<string, string>();
|
|
16
21
|
|
|
17
22
|
public constructor(private readonly _pkgPath: string,
|
|
@@ -30,7 +35,13 @@ export class SdTsIncrementalBuilder {
|
|
|
30
35
|
transforms?: IOptTransform<any>[]
|
|
31
36
|
}): Promise<SdTsIncrementalBuilder> {
|
|
32
37
|
const tsConfigFilePath = path.resolve(pkgPath, "tsconfig.json");
|
|
33
|
-
const
|
|
38
|
+
const tsConfig = await FsUtil.readJsonAsync(tsConfigFilePath);
|
|
39
|
+
const parsedTsConfig = ts.parseJsonConfigFileContent(
|
|
40
|
+
await FsUtil.readJsonAsync(tsConfigFilePath),
|
|
41
|
+
ts.sys,
|
|
42
|
+
pkgPath,
|
|
43
|
+
tsConfig["angularCompilerOptions"]
|
|
44
|
+
);
|
|
34
45
|
const opt = optFn(parsedTsConfig.options);
|
|
35
46
|
const compilerOptions = {
|
|
36
47
|
...parsedTsConfig.options,
|
|
@@ -54,9 +65,40 @@ export class SdTsIncrementalBuilder {
|
|
|
54
65
|
const distPath = this._compilerOptions.outDir ?? path.resolve(this._pkgPath, "dist");
|
|
55
66
|
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.{ts,tsx}");
|
|
56
67
|
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
68
|
+
|
|
69
|
+
if (this._compilerOptions["strictTemplates"] === true) {
|
|
70
|
+
this._ngProgram = new NgtscProgram(
|
|
71
|
+
srcFilePaths,
|
|
72
|
+
this._compilerOptions,
|
|
73
|
+
this._host,
|
|
74
|
+
this._ngProgram
|
|
75
|
+
);
|
|
76
|
+
this._program = this._ngProgram.getTsProgram();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this._program = ts.createProgram(
|
|
80
|
+
srcFilePaths,
|
|
81
|
+
this._compilerOptions,
|
|
82
|
+
this._host,
|
|
83
|
+
this._program
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const baseGetSourceFiles = this._program.getSourceFiles;
|
|
88
|
+
this._program.getSourceFiles = function (...parameters) {
|
|
89
|
+
const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);
|
|
90
|
+
|
|
91
|
+
for (const file of files) {
|
|
92
|
+
if (file.version === undefined) {
|
|
93
|
+
file.version = createHash("sha256").update(file.text).digest("hex");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return files;
|
|
98
|
+
};
|
|
99
|
+
|
|
57
100
|
this.builderProgram = ts.createSemanticDiagnosticsBuilderProgram(
|
|
58
|
-
|
|
59
|
-
this._compilerOptions,
|
|
101
|
+
this._program,
|
|
60
102
|
this._host,
|
|
61
103
|
this.builderProgram
|
|
62
104
|
);
|
|
@@ -64,25 +106,52 @@ export class SdTsIncrementalBuilder {
|
|
|
64
106
|
const diagnostics: ts.Diagnostic[] = [];
|
|
65
107
|
const affectedFilePaths: string[] = [];
|
|
66
108
|
|
|
109
|
+
if (this._ngProgram) {
|
|
110
|
+
diagnostics.push(...this._ngProgram.compiler.getOptionDiagnostics());
|
|
111
|
+
}
|
|
112
|
+
|
|
67
113
|
diagnostics.push(
|
|
68
114
|
...this.builderProgram.getOptionsDiagnostics(),
|
|
69
115
|
...this.builderProgram.getGlobalDiagnostics(),
|
|
70
116
|
);
|
|
71
117
|
|
|
118
|
+
if (this._ngProgram) {
|
|
119
|
+
await this._ngProgram.compiler.analyzeAsync();
|
|
120
|
+
}
|
|
121
|
+
|
|
72
122
|
const program = this.builderProgram.getProgram();
|
|
73
123
|
|
|
74
124
|
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리중...`);
|
|
75
125
|
const srcFilePathSet = new Set<string>(srcFilePaths);
|
|
76
126
|
while (true) {
|
|
127
|
+
let affectedSourceFile: ts.SourceFile | undefined;
|
|
128
|
+
|
|
77
129
|
const semanticResult = this.builderProgram.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
78
|
-
|
|
130
|
+
//-- ngtypecheck의 org파일 포함 (ngtypecheck 파일는 무시)
|
|
131
|
+
if (this._ngProgram?.compiler.ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
|
|
132
|
+
const orgFileName = sourceFile.fileName.slice(0, -15) + ".ts";
|
|
133
|
+
const orgSourceFile = this.builderProgram!.getSourceFile(orgFileName);
|
|
134
|
+
if (orgSourceFile) {
|
|
135
|
+
affectedSourceFile = orgSourceFile;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
//-- 소스폴더 파일 포함
|
|
140
|
+
else if (srcFilePathSet.has(path.resolve(sourceFile.fileName))) {
|
|
141
|
+
affectedSourceFile = sourceFile;
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
//-- 나머지 무시
|
|
145
|
+
else {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
79
148
|
});
|
|
80
|
-
if (!semanticResult) break;
|
|
149
|
+
if (!semanticResult || !affectedSourceFile) break;
|
|
81
150
|
diagnostics.push(...semanticResult.result);
|
|
82
151
|
|
|
83
|
-
if ("fileName" in
|
|
152
|
+
if ("fileName" in affectedSourceFile) {
|
|
84
153
|
const emitResult = this.builderProgram.emit
|
|
85
|
-
(
|
|
154
|
+
(affectedSourceFile,
|
|
86
155
|
(filePath, data, writeByteOrderMark) => {
|
|
87
156
|
let realFilePath = filePath;
|
|
88
157
|
let realData = data;
|
|
@@ -91,6 +160,7 @@ export class SdTsIncrementalBuilder {
|
|
|
91
160
|
|
|
92
161
|
if (filePath.endsWith(".js.map")) {
|
|
93
162
|
const sourceMapContents = JSON.parse(realData);
|
|
163
|
+
// remove "../../"
|
|
94
164
|
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
95
165
|
realData = JSON.stringify(sourceMapContents);
|
|
96
166
|
}
|
|
@@ -102,15 +172,27 @@ export class SdTsIncrementalBuilder {
|
|
|
102
172
|
this._writeFileCache.set(realFilePath, realData);
|
|
103
173
|
},
|
|
104
174
|
undefined,
|
|
105
|
-
Array.isArray(this._opt.emitJs) ? !this._opt.emitJs.includes(path.resolve(
|
|
175
|
+
Array.isArray(this._opt.emitJs) ? !this._opt.emitJs.includes(path.resolve(affectedSourceFile.fileName)) : !this._opt.emitJs,
|
|
106
176
|
this._opt.transforms ? {
|
|
107
177
|
before: this._opt.transforms.map((item) => typeof item.fn === "function" ? item.fn(program, item.args) : (item.fn["default"] as any)(program, item.args))
|
|
108
178
|
} : undefined
|
|
109
179
|
);
|
|
110
180
|
diagnostics.push(...emitResult.diagnostics);
|
|
111
181
|
|
|
112
|
-
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(
|
|
113
|
-
|
|
182
|
+
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(affectedSourceFile));
|
|
183
|
+
|
|
184
|
+
if (
|
|
185
|
+
this._ngProgram &&
|
|
186
|
+
!affectedSourceFile.isDeclarationFile &&
|
|
187
|
+
!this._ngProgram.compiler.ignoreForEmit.has(affectedSourceFile) &&
|
|
188
|
+
!this._ngProgram.compiler.incrementalCompilation.safeToSkipEmit(affectedSourceFile)
|
|
189
|
+
) {
|
|
190
|
+
diagnostics.push(
|
|
191
|
+
...this._ngProgram.compiler.getDiagnosticsForFile(affectedSourceFile, 1)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
affectedFilePaths.push(path.resolve(affectedSourceFile.fileName));
|
|
114
196
|
}
|
|
115
197
|
}
|
|
116
198
|
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리 완료`, affectedFilePaths);
|