@simplysm/sd-cli 10.0.36 → 10.0.39
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/SdLinter.js.map +1 -1
- package/dist/SdTsIncrementalBuilder.d.ts +17 -4
- package/dist/SdTsIncrementalBuilder.js +29 -33
- package/dist/SdTsIncrementalBuilder.js.map +1 -1
- package/dist/build-cluster.js +98 -30
- package/dist/build-cluster.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.d.ts +6 -2
- package/dist/builders/SdCliClientBuilder.js +107 -97
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliJsLibLinter.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +2 -1
- package/dist/builders/SdCliServerBuilder.js +68 -13
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +5 -2
- package/dist/builders/SdCliTsLibBuilder.js +64 -10
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +28 -2
- package/dist/commons.js.map +1 -1
- package/dist/entry/SdCliElectron.d.ts +7 -0
- package/dist/entry/SdCliElectron.js +42 -0
- package/dist/entry/SdCliElectron.js.map +1 -0
- package/dist/entry/SdCliLocalUpdate.d.ts +3 -3
- package/dist/entry/SdCliLocalUpdate.js +20 -26
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +3 -3
- package/dist/entry/SdCliProject.js +87 -36
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sd-cli.d.ts +1 -1
- package/dist/sd-cli.js +62 -16
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.js +1 -1
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/dist/utils/SdCliViteElectronMainPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js +81 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -0
- package/dist/utils/SdCliViteExternalPlugin.d.ts +7 -0
- package/dist/utils/SdCliViteExternalPlugin.js +98 -0
- package/dist/utils/SdCliViteExternalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteLoggerPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteLoggerPlugin.js +24 -0
- package/dist/utils/SdCliViteLoggerPlugin.js.map +1 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js +29 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteReactSwcPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js +141 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js +26 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js.map +1 -0
- package/dist/utils/getElectronReactExternals.d.ts +1 -0
- package/dist/utils/getElectronReactExternals.js +17 -0
- package/dist/utils/getElectronReactExternals.js.map +1 -0
- package/dist/utils/sdCliTsDefineTransformer.d.ts +4 -0
- package/dist/utils/sdCliTsDefineTransformer.js +26 -0
- package/dist/utils/sdCliTsDefineTransformer.js.map +1 -0
- package/package.json +25 -10
- package/src/SdLinter.ts +2 -2
- package/src/SdTsIncrementalBuilder.ts +116 -94
- package/src/build-cluster.ts +173 -111
- package/src/builders/SdCliClientBuilder.ts +226 -204
- package/src/builders/SdCliServerBuilder.ts +311 -240
- package/src/builders/SdCliTsLibBuilder.ts +160 -89
- package/src/commons.ts +66 -34
- package/src/entry/SdCliElectron.ts +55 -0
- package/src/entry/SdCliLocalUpdate.ts +104 -101
- package/src/entry/SdCliProject.ts +452 -401
- package/src/index.ts +1 -0
- package/src/sd-cli.ts +185 -141
- package/src/utils/SdCliBuildResultUtil.ts +1 -2
- package/src/utils/SdCliViteElectronMainPlugin.ts +86 -0
- package/src/utils/SdCliViteExternalPlugin.ts +112 -0
- package/src/utils/SdCliViteLoggerPlugin.ts +29 -0
- package/src/utils/SdCliViteNodeGlobalPlugin.ts +31 -0
- package/src/utils/SdCliViteReactSwcPlugin.ts +154 -0
- package/src/utils/SdCliViteWatchWithResolutionsPlugin.ts +29 -0
- package/src/utils/getElectronReactExternals.ts +19 -0
- package/src/utils/sdCliTsDefineTransformer.ts +31 -0
- package/.eslintrc.cjs +0 -18
- package/dist/utils/SdCliConfigUtil.d.ts +0 -7
- package/dist/utils/SdCliConfigUtil.js +0 -69
- package/dist/utils/SdCliConfigUtil.js.map +0 -1
- package/src/utils/SdCliConfigUtil.ts +0 -94
|
@@ -1,58 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {EventEmitter} from "events";
|
|
2
|
+
import {FsUtil, Logger} from "@simplysm/sd-core-node";
|
|
3
|
+
import {INpmConfig, ISdCliBuilderResult, ISdCliServerPackageConfig} from "../commons";
|
|
4
4
|
import esbuild from "esbuild";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import {SdTsIncrementalBuilder} from "../SdTsIncrementalBuilder";
|
|
7
|
+
import {SdLinter} from "../SdLinter";
|
|
8
|
+
import {StringUtil} from "@simplysm/sd-core-common";
|
|
9
|
+
import esbuildPluginTsc from 'esbuild-plugin-tsc';
|
|
9
10
|
|
|
10
11
|
export class SdCliServerBuilder extends EventEmitter {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
12
|
+
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
|
|
13
|
+
|
|
14
|
+
public constructor(private readonly _pkgPath: string,
|
|
15
|
+
private readonly _pkgConf: ISdCliServerPackageConfig,
|
|
16
|
+
private readonly _withLint: boolean) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public override on(event: "change", listener: () => void): this;
|
|
21
|
+
public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
|
|
22
|
+
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
23
|
+
super.on(event, listener);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async watchAsync(): Promise<void> {
|
|
28
|
+
this._debug("빌드 준비...");
|
|
29
|
+
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: false}));
|
|
30
|
+
|
|
31
|
+
this._debug("dist 초기화...");
|
|
32
|
+
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
33
|
+
|
|
34
|
+
this.emit("change");
|
|
35
|
+
|
|
36
|
+
this._debug("GEN .config...");
|
|
37
|
+
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
38
|
+
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
39
|
+
|
|
40
|
+
this._debug(`BUILD...`);
|
|
41
|
+
const extModules = await this._getExternalModulesAsync();
|
|
42
|
+
let isFirst = true;
|
|
43
|
+
const ctx = await esbuild.context({
|
|
44
|
+
entryPoints: {
|
|
45
|
+
index: path.resolve(this._pkgPath, "src", "main.ts")
|
|
46
|
+
},
|
|
47
|
+
keepNames: true,
|
|
48
|
+
bundle: true,
|
|
49
|
+
target: "node20",
|
|
50
|
+
mainFields: ["es2021", "es2020", "module", "main"],
|
|
51
|
+
conditions: ["es2021", "es2020", "es2015", "module"],
|
|
52
|
+
tsconfig: path.resolve(this._pkgPath, "tsconfig.json"),
|
|
53
|
+
write: true,
|
|
54
|
+
format: "esm",
|
|
55
|
+
// outExtension: { ".js": ".mjs" },
|
|
56
|
+
resolveExtensions: [".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx"],
|
|
57
|
+
loader: {
|
|
58
|
+
".pfx": "binary"
|
|
59
|
+
},
|
|
60
|
+
platform: "node",
|
|
61
|
+
logLevel: "silent",
|
|
62
|
+
outfile: path.resolve(this._pkgPath, "dist", "main.js"),
|
|
63
|
+
external: extModules.map((item) => item.name),
|
|
64
|
+
banner: {
|
|
65
|
+
js: `
|
|
56
66
|
import __path__ from 'path';
|
|
57
67
|
import { fileURLToPath as __fileURLToPath__ } from 'url';
|
|
58
68
|
import { createRequire as __createRequire__ } from 'module';
|
|
@@ -60,90 +70,115 @@ import { createRequire as __createRequire__ } from 'module';
|
|
|
60
70
|
const require = __createRequire__(import.meta.url);
|
|
61
71
|
const __filename = __fileURLToPath__(import.meta.url);
|
|
62
72
|
const __dirname = __path__.dirname(__filename);`.trim()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
73
|
+
},
|
|
74
|
+
plugins: [
|
|
75
|
+
esbuildPluginTsc(),
|
|
76
|
+
{
|
|
77
|
+
name: "sd-additional",
|
|
78
|
+
setup: ({
|
|
79
|
+
onEnd,
|
|
80
|
+
onStart
|
|
81
|
+
}) => {
|
|
82
|
+
onStart(() => {
|
|
83
|
+
if (!isFirst) {
|
|
84
|
+
this.emit("change");
|
|
85
|
+
this._debug(`BUILD...`);
|
|
86
|
+
}
|
|
87
|
+
isFirst = false;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
onEnd(async (result) => {
|
|
91
|
+
try {
|
|
92
|
+
const buildResults = [
|
|
93
|
+
...result.warnings.map((warn) => ({
|
|
94
|
+
filePath: warn.location?.file !== undefined ? path.resolve(warn.location.file) : undefined,
|
|
95
|
+
line: warn.location?.line,
|
|
96
|
+
char: warn.location?.column,
|
|
97
|
+
code: undefined,
|
|
98
|
+
severity: "warning" as const,
|
|
99
|
+
message: warn.text
|
|
100
|
+
})),
|
|
101
|
+
...result.errors.map((err) => ({
|
|
102
|
+
filePath: err.location?.file !== undefined ? path.resolve(err.location.file) : undefined,
|
|
103
|
+
line: err.location?.line,
|
|
104
|
+
char: err.location?.column !== undefined ? err.location.column + 1 : undefined,
|
|
105
|
+
code: undefined,
|
|
106
|
+
severity: "error" as const,
|
|
107
|
+
message: err.text
|
|
108
|
+
}))
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
this._debug("CHECK...");
|
|
112
|
+
const checkResult = await sdTsProgram.buildAsync();
|
|
113
|
+
|
|
114
|
+
this._debug("LINT...");
|
|
115
|
+
const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(checkResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
116
|
+
|
|
117
|
+
this._debug(`빌드 완료`);
|
|
118
|
+
this.emit("complete", {
|
|
119
|
+
affectedFilePaths: checkResult.affectedFilePaths,
|
|
120
|
+
buildResults: [...buildResults, ...checkResult.results, ...lintResults]
|
|
121
|
+
});
|
|
122
|
+
} catch (err) {
|
|
123
|
+
this._logger.error(err);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "jsdom-patch",
|
|
130
|
+
setup: ({onLoad}) => {
|
|
131
|
+
onLoad({filter: /XMLHttpRequest-impl\.js$/}, async (args) => {
|
|
132
|
+
let contents = await FsUtil.readFileAsync(args.path);
|
|
133
|
+
contents = contents.replace(
|
|
134
|
+
'./xhr-sync-worker.js',
|
|
135
|
+
'jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js'
|
|
136
|
+
);
|
|
137
|
+
return {contents};
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
await ctx.watch();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
147
|
+
this._debug("빌드 준비...");
|
|
148
|
+
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: false}));
|
|
149
|
+
|
|
150
|
+
this._debug("dist 초기화...");
|
|
151
|
+
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
152
|
+
|
|
153
|
+
this._debug("GEN .config...");
|
|
154
|
+
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
155
|
+
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
156
|
+
|
|
157
|
+
this._debug("BUILD...");
|
|
158
|
+
const extModules = await this._getExternalModulesAsync();
|
|
159
|
+
const esbuildResult = await esbuild.build({
|
|
160
|
+
entryPoints: {
|
|
161
|
+
index: path.resolve(this._pkgPath, "src", "main.ts")
|
|
162
|
+
},
|
|
163
|
+
keepNames: true,
|
|
164
|
+
bundle: true,
|
|
165
|
+
target: "node20",
|
|
166
|
+
mainFields: ["es2021", "es2020", "module", "main"],
|
|
167
|
+
conditions: ["es2021", "es2020", "es2015", "module"],
|
|
168
|
+
tsconfig: path.resolve(this._pkgPath, "tsconfig.json"),
|
|
169
|
+
write: true,
|
|
170
|
+
format: "esm",
|
|
171
|
+
// outExtension: { ".js": ".mjs" },
|
|
172
|
+
resolveExtensions: [".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx"],
|
|
173
|
+
loader: {
|
|
174
|
+
".pfx": "binary"
|
|
175
|
+
},
|
|
176
|
+
platform: "node",
|
|
177
|
+
logLevel: "silent",
|
|
178
|
+
outfile: path.resolve(this._pkgPath, "dist", "main.js"),
|
|
179
|
+
external: extModules.map((item) => item.name),
|
|
180
|
+
banner: {
|
|
181
|
+
js: `
|
|
147
182
|
import __path__ from 'path';
|
|
148
183
|
import { fileURLToPath as __fileURLToPath__ } from 'url';
|
|
149
184
|
import { createRequire as __createRequire__ } from 'module';
|
|
@@ -151,109 +186,145 @@ import { createRequire as __createRequire__ } from 'module';
|
|
|
151
186
|
const require = __createRequire__(import.meta.url);
|
|
152
187
|
const __filename = __fileURLToPath__(import.meta.url);
|
|
153
188
|
const __dirname = __path__.dirname(__filename);`.trim()
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
189
|
+
},
|
|
190
|
+
plugins: [
|
|
191
|
+
{
|
|
192
|
+
name: "jsdom-patch",
|
|
193
|
+
setup: ({onLoad}) => {
|
|
194
|
+
onLoad({filter: /XMLHttpRequest-impl\.js$/}, async (args) => {
|
|
195
|
+
let contents = await FsUtil.readFileAsync(args.path);
|
|
196
|
+
contents = contents.replace(
|
|
197
|
+
'./xhr-sync-worker.js',
|
|
198
|
+
'jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js'
|
|
199
|
+
);
|
|
200
|
+
return {contents};
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const buildResults = [
|
|
208
|
+
...esbuildResult.warnings.map((warn) => ({
|
|
209
|
+
filePath: warn.location?.file !== undefined ? path.resolve(warn.location.file) : undefined,
|
|
210
|
+
line: warn.location?.line,
|
|
211
|
+
char: warn.location?.column,
|
|
212
|
+
code: undefined,
|
|
213
|
+
severity: "warning" as const,
|
|
214
|
+
message: warn.text
|
|
215
|
+
})),
|
|
216
|
+
...esbuildResult.errors.map((err) => ({
|
|
217
|
+
filePath: err.location?.file !== undefined ? path.resolve(err.location.file) : undefined,
|
|
218
|
+
line: err.location?.line,
|
|
219
|
+
char: err.location?.column !== undefined ? err.location.column + 1 : undefined,
|
|
220
|
+
code: undefined,
|
|
221
|
+
severity: "warning" as const,
|
|
222
|
+
message: err.text
|
|
223
|
+
}))
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
this._debug("CHECK...");
|
|
227
|
+
const checkResult = await sdTsProgram.buildAsync();
|
|
228
|
+
|
|
229
|
+
this._debug("LINT...");
|
|
230
|
+
const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(checkResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
231
|
+
|
|
232
|
+
this._debug(`빌드 완료`);
|
|
233
|
+
return {
|
|
234
|
+
affectedFilePaths: checkResult.affectedFilePaths,
|
|
235
|
+
buildResults: [...buildResults, ...checkResult.results, ...lintResults]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private async _getExternalModulesAsync(): Promise<{
|
|
240
|
+
name: string;
|
|
241
|
+
exists: boolean
|
|
242
|
+
}[]> {
|
|
243
|
+
const loadedModuleNames: string[] = [];
|
|
244
|
+
const results: {
|
|
245
|
+
name: string;
|
|
246
|
+
exists: boolean
|
|
247
|
+
}[] = [];
|
|
248
|
+
|
|
249
|
+
const npmConfigMap = new Map<string, INpmConfig>();
|
|
250
|
+
|
|
251
|
+
const fn = async (currPath: string): Promise<void> => {
|
|
252
|
+
const npmConfig = npmConfigMap.getOrCreate(currPath, await FsUtil.readJsonAsync(path.resolve(currPath, "package.json")));
|
|
253
|
+
|
|
254
|
+
const deps = {
|
|
255
|
+
defaults: [
|
|
256
|
+
...Object.keys(npmConfig.dependencies ?? {}),
|
|
257
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
258
|
+
].distinct(),
|
|
259
|
+
optionals: [
|
|
260
|
+
...Object.keys(npmConfig.optionalDependencies ?? {}),
|
|
261
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
262
|
+
].distinct()
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
for (const moduleName of deps.defaults) {
|
|
266
|
+
if (loadedModuleNames.includes(moduleName)) continue;
|
|
267
|
+
loadedModuleNames.push(moduleName);
|
|
268
|
+
|
|
269
|
+
const modulePath = FsUtil.findAllParentChildPaths("node_modules/" + moduleName, currPath, path.resolve(this._pkgPath, "../../")).first();
|
|
270
|
+
if (StringUtil.isNullOrEmpty(modulePath)) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (FsUtil.glob(path.resolve(modulePath, "**/binding.gyp")).length > 0) {
|
|
275
|
+
results.push({
|
|
276
|
+
name: moduleName,
|
|
277
|
+
exists: true
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (this._pkgConf.externals?.includes(moduleName)) {
|
|
282
|
+
results.push({
|
|
283
|
+
name: moduleName,
|
|
284
|
+
exists: true
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
await fn(modulePath);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
for (const optModuleName of deps.optionals) {
|
|
292
|
+
if (loadedModuleNames.includes(optModuleName)) continue;
|
|
293
|
+
loadedModuleNames.push(optModuleName);
|
|
294
|
+
|
|
295
|
+
const optModulePath = FsUtil.findAllParentChildPaths("node_modules/" + optModuleName, currPath, path.resolve(this._pkgPath, "../../")).first();
|
|
296
|
+
if (StringUtil.isNullOrEmpty(optModulePath)) {
|
|
297
|
+
results.push({
|
|
298
|
+
name: optModuleName,
|
|
299
|
+
exists: false
|
|
300
|
+
});
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (FsUtil.glob(path.resolve(optModulePath, "**/binding.gyp")).length > 0) {
|
|
305
|
+
results.push({
|
|
306
|
+
name: optModuleName,
|
|
307
|
+
exists: true
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (this._pkgConf.externals?.includes(optModuleName)) {
|
|
312
|
+
results.push({
|
|
313
|
+
name: optModuleName,
|
|
314
|
+
exists: true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
await fn(optModulePath);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
await fn(this._pkgPath);
|
|
323
|
+
|
|
324
|
+
return results;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private _debug(msg: string): void {
|
|
328
|
+
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
329
|
+
}
|
|
259
330
|
}
|