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