@simplysm/sd-cli 12.13.20 → 12.13.21
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/pkg-builders/client/sd-cli-ng-routes.file-generator.d.ts +1 -0
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js +16 -11
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +1 -1
- package/dist/pkg-builders/client/sd-client.build-runner.js +7 -17
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler.js +105 -95
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
- package/dist/pkg-builders/commons/build-runner.base.d.ts +2 -1
- package/dist/pkg-builders/commons/build-runner.base.js +16 -27
- package/dist/pkg-builders/commons/build-runner.base.js.map +1 -1
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.d.ts +1 -0
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js +21 -11
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +1 -0
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +13 -10
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +11 -30
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.bundler.js +48 -37
- package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
- package/package.json +5 -5
- package/src/pkg-builders/client/sd-cli-ng-routes.file-generator.ts +18 -8
- package/src/pkg-builders/client/sd-client.build-runner.ts +8 -19
- package/src/pkg-builders/client/sd-ng.bundler.ts +139 -121
- package/src/pkg-builders/commons/build-runner.base.ts +62 -75
- package/src/pkg-builders/lib/sd-cli-db-context.file-generator.ts +20 -8
- package/src/pkg-builders/lib/sd-cli-index.file-generator.ts +20 -9
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +11 -31
- package/src/pkg-builders/server/sd-server.bundler.ts +59 -48
|
@@ -26,11 +26,17 @@ import {
|
|
|
26
26
|
import { Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
|
|
27
27
|
import { CrossOrigin } from "@angular/build/src/builders/application/schema";
|
|
28
28
|
import { augmentAppWithServiceWorkerEsbuild } from "@angular/build/src/utils/service-worker";
|
|
29
|
-
import {
|
|
30
|
-
|
|
29
|
+
import {
|
|
30
|
+
createSourcemapIgnorelistPlugin
|
|
31
|
+
} from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
32
|
+
import {
|
|
33
|
+
StylesheetPluginFactory
|
|
34
|
+
} from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
31
35
|
import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/sass-language";
|
|
32
36
|
import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
|
|
33
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
createCssResourcePlugin
|
|
39
|
+
} from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
34
40
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
35
41
|
import { createSdNgPlugin } from "./sd-ng.plugin-creator";
|
|
36
42
|
import { SdCliPerformanceTimer } from "../../utils/sd-cli-performance-time";
|
|
@@ -130,142 +136,154 @@ export class SdNgBundler {
|
|
|
130
136
|
//-- results
|
|
131
137
|
const results = bundlingResults.mapMany((bundlingResult) => bundlingResult.results);
|
|
132
138
|
|
|
133
|
-
this
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
for (const bundlingResult of bundlingResults) {
|
|
148
|
-
bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
|
|
149
|
-
metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
|
|
150
|
-
metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
|
|
151
|
-
}
|
|
152
|
-
const assetFiles: { source: string; destination: string }[] = [];
|
|
153
|
-
|
|
154
|
-
//-- cordova empty
|
|
155
|
-
/*if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
156
|
-
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
157
|
-
}*/
|
|
158
|
-
|
|
159
|
-
this.#debug(`create index.html...`);
|
|
160
|
-
await perf.run("create index.html", async () => {
|
|
161
|
-
const genIndexHtmlResult = await this.#genIndexHtmlAsync(outputFiles, initialFiles);
|
|
162
|
-
for (const warning of genIndexHtmlResult.warnings) {
|
|
163
|
-
results.push({
|
|
164
|
-
filePath: undefined,
|
|
165
|
-
line: undefined,
|
|
166
|
-
char: undefined,
|
|
167
|
-
code: undefined,
|
|
168
|
-
severity: "warning",
|
|
169
|
-
message: `${warning}`,
|
|
170
|
-
type: "gen-index",
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
for (const error of genIndexHtmlResult.errors) {
|
|
174
|
-
results.push({
|
|
175
|
-
filePath: undefined,
|
|
176
|
-
line: undefined,
|
|
177
|
-
char: undefined,
|
|
178
|
-
code: undefined,
|
|
179
|
-
severity: "error",
|
|
180
|
-
message: `${error}`,
|
|
181
|
-
type: "gen-index",
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
outputFiles.push(
|
|
185
|
-
createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root),
|
|
139
|
+
if (this._opt.noEmit) {
|
|
140
|
+
return {
|
|
141
|
+
watchFileSet: this.#ngResultCache.watchFileSet!,
|
|
142
|
+
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
143
|
+
results,
|
|
144
|
+
emitFileSet: new Set<TNormPath>(),
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
this.#debug(`convert result...`);
|
|
148
|
+
|
|
149
|
+
const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(
|
|
150
|
+
(item) =>
|
|
151
|
+
item.outputFiles?.map((file) => convertOutputFile(file, BuildOutputFileType.Root)) ?? [],
|
|
186
152
|
);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
BuildOutputFileType.Root,
|
|
200
|
-
),
|
|
201
|
-
);
|
|
153
|
+
const initialFiles = new Map<string, InitialFileRecord>();
|
|
154
|
+
const metafile: {
|
|
155
|
+
inputs: Metafile["inputs"];
|
|
156
|
+
outputs: Metafile["outputs"];
|
|
157
|
+
} = {
|
|
158
|
+
inputs: {},
|
|
159
|
+
outputs: {},
|
|
160
|
+
};
|
|
161
|
+
for (const bundlingResult of bundlingResults) {
|
|
162
|
+
bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
|
|
163
|
+
metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
|
|
164
|
+
metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
|
|
202
165
|
}
|
|
203
|
-
});
|
|
204
166
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
167
|
+
//-- cordova empty
|
|
168
|
+
/*if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
169
|
+
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
170
|
+
}*/
|
|
208
171
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
172
|
+
this.#debug(`create index.html...`);
|
|
173
|
+
await perf.run("create index.html", async () => {
|
|
174
|
+
const genIndexHtmlResult = await this.#genIndexHtmlAsync(outputFiles, initialFiles);
|
|
175
|
+
for (const warning of genIndexHtmlResult.warnings) {
|
|
176
|
+
results.push({
|
|
177
|
+
filePath: undefined,
|
|
178
|
+
line: undefined,
|
|
179
|
+
char: undefined,
|
|
180
|
+
code: undefined,
|
|
181
|
+
severity: "warning",
|
|
182
|
+
message: `${warning}`,
|
|
183
|
+
type: "gen-index",
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
for (const error of genIndexHtmlResult.errors) {
|
|
217
187
|
results.push({
|
|
218
188
|
filePath: undefined,
|
|
219
189
|
line: undefined,
|
|
220
190
|
char: undefined,
|
|
221
191
|
code: undefined,
|
|
222
192
|
severity: "error",
|
|
223
|
-
message: `${
|
|
224
|
-
type: "gen-
|
|
193
|
+
message: `${error}`,
|
|
194
|
+
type: "gen-index",
|
|
225
195
|
});
|
|
226
196
|
}
|
|
197
|
+
outputFiles.push(
|
|
198
|
+
createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root),
|
|
199
|
+
);
|
|
227
200
|
});
|
|
228
|
-
}
|
|
229
201
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
202
|
+
const assetFiles: { source: string; destination: string }[] = [];
|
|
203
|
+
await perf.run("assets", async () => {
|
|
204
|
+
//-- copy assets
|
|
205
|
+
assetFiles.push(...(await this.#copyAssetsAsync()));
|
|
206
|
+
|
|
207
|
+
//-- extract 3rdpartylicenses
|
|
208
|
+
if (!this._opt.dev) {
|
|
209
|
+
outputFiles.push(
|
|
210
|
+
createOutputFile(
|
|
211
|
+
"3rdpartylicenses.txt",
|
|
212
|
+
await extractLicenses(metafile, this._opt.pkgPath),
|
|
213
|
+
BuildOutputFileType.Root,
|
|
214
|
+
),
|
|
215
|
+
);
|
|
243
216
|
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
//-- service worker
|
|
220
|
+
if (FsUtils.exists(this.#swConfFilePath)) {
|
|
221
|
+
this.#debug(`prepare service worker...`);
|
|
222
|
+
|
|
223
|
+
await perf.run("prepare service worker", async () => {
|
|
224
|
+
try {
|
|
225
|
+
const serviceWorkerResult = await this.#genServiceWorkerAsync(outputFiles, assetFiles);
|
|
226
|
+
outputFiles.push(
|
|
227
|
+
createOutputFile("ngsw.json", serviceWorkerResult.manifest, BuildOutputFileType.Root),
|
|
228
|
+
);
|
|
229
|
+
assetFiles.push(...serviceWorkerResult.assetFiles);
|
|
230
|
+
} catch (err) {
|
|
231
|
+
results.push({
|
|
232
|
+
filePath: undefined,
|
|
233
|
+
line: undefined,
|
|
234
|
+
char: undefined,
|
|
235
|
+
code: undefined,
|
|
236
|
+
severity: "error",
|
|
237
|
+
message: `${err.toString()}`,
|
|
238
|
+
type: "gen-sw",
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
});
|
|
244
242
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
243
|
+
|
|
244
|
+
//-- write
|
|
245
|
+
this.#debug(`write output files...(${outputFiles.length})`);
|
|
246
|
+
|
|
247
|
+
const emitFileSet = new Set<TNormPath>();
|
|
248
|
+
perf.run("write output file", () => {
|
|
249
|
+
for (const outputFile of outputFiles) {
|
|
250
|
+
const distFilePath = PathUtils.norm(this._opt.outputPath, outputFile.path);
|
|
251
|
+
const prevHash = this.#outputHashCache.get(distFilePath);
|
|
252
|
+
const currHash = HashUtils.get(Buffer.from(outputFile.contents));
|
|
253
|
+
if (prevHash !== currHash) {
|
|
254
|
+
FsUtils.writeFile(distFilePath, outputFile.contents);
|
|
255
|
+
this.#outputHashCache.set(distFilePath, currHash);
|
|
256
|
+
emitFileSet.add(distFilePath);
|
|
257
|
+
}
|
|
252
258
|
}
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
for (const assetFile of assetFiles) {
|
|
260
|
+
const prevHash = this.#outputHashCache.get(PathUtils.norm(assetFile.source));
|
|
261
|
+
const currHash = HashUtils.get(FsUtils.readFileBuffer(assetFile.source));
|
|
262
|
+
if (prevHash !== currHash) {
|
|
263
|
+
FsUtils.copy(
|
|
264
|
+
assetFile.source,
|
|
265
|
+
path.resolve(this._opt.outputPath, assetFile.destination),
|
|
266
|
+
);
|
|
267
|
+
this.#outputHashCache.set(PathUtils.norm(assetFile.source), currHash);
|
|
268
|
+
emitFileSet.add(PathUtils.norm(this._opt.outputPath, assetFile.destination));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
255
272
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
this.#debug(perf.toString());
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
watchFileSet: new Set([
|
|
277
|
+
...this.#ngResultCache.watchFileSet!,
|
|
278
|
+
...this.#styleLoadResultCache.watchFiles.map((item) => PathUtils.norm(item)),
|
|
279
|
+
...assetFiles.map((item) => PathUtils.norm(item.source)),
|
|
280
|
+
PathUtils.norm(this.#indexHtmlFilePath),
|
|
281
|
+
]),
|
|
282
|
+
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
283
|
+
results,
|
|
284
|
+
emitFileSet: emitFileSet,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
269
287
|
}
|
|
270
288
|
|
|
271
289
|
async #genIndexHtmlAsync(
|
|
@@ -30,7 +30,7 @@ export abstract class BuildRunnerBase<
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
constructor(
|
|
33
|
-
|
|
33
|
+
protected _projConf: ISdProjectConfig,
|
|
34
34
|
protected _pkgPath: TNormPath,
|
|
35
35
|
workspaceGlobs: string[],
|
|
36
36
|
protected _emitOnly: boolean,
|
|
@@ -39,12 +39,16 @@ export abstract class BuildRunnerBase<
|
|
|
39
39
|
super();
|
|
40
40
|
|
|
41
41
|
this._pkgName = path.basename(_pkgPath);
|
|
42
|
-
this._pkgConf =
|
|
42
|
+
this._pkgConf = _projConf.packages[this._pkgName] as TSdPackageConfig<T>;
|
|
43
43
|
|
|
44
44
|
const workspacePaths = workspaceGlobs
|
|
45
|
-
.
|
|
45
|
+
.mapMany((item) => [
|
|
46
|
+
PathUtils.posix(this._pkgPath, "../../", item, "src"),
|
|
47
|
+
PathUtils.posix(this._pkgPath, "../../", item, "public"),
|
|
48
|
+
PathUtils.posix(this._pkgPath, "../../", item, "public-dev"),
|
|
49
|
+
])
|
|
46
50
|
.mapMany((item) => FsUtils.glob(item));
|
|
47
|
-
const localUpdatePaths = Object.keys(
|
|
51
|
+
const localUpdatePaths = Object.keys(_projConf.localUpdates ?? {}).mapMany((key) => [
|
|
48
52
|
...FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key, "dist")),
|
|
49
53
|
...FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key, "src/**/*.scss")),
|
|
50
54
|
]);
|
|
@@ -94,87 +98,70 @@ export abstract class BuildRunnerBase<
|
|
|
94
98
|
this.emit("complete", res);
|
|
95
99
|
|
|
96
100
|
this._debug("WATCH...");
|
|
97
|
-
let lastWatchFileSet = result.watchFileSet;
|
|
98
|
-
SdFsWatcher.watch(this._watchScopePathSet.toArray(), {
|
|
99
|
-
ignore: (filePath) =>
|
|
100
|
-
(this._pkgConf.type === "client" &&
|
|
101
|
-
path.dirname(path.basename(filePath)) === "src" &&
|
|
102
|
-
path.basename(filePath) === `routes.ts`) ||
|
|
103
|
-
(this._pkgConf.type === "library" &&
|
|
104
|
-
this._pkgConf.dbContext != null &&
|
|
105
|
-
path.dirname(path.basename(filePath)) === "src" &&
|
|
106
|
-
path.basename(filePath) === `${this._pkgConf.dbContext}.ts`) ||
|
|
107
|
-
(this._pkgConf.type === "library" &&
|
|
108
|
-
!this._pkgConf.noGenIndex &&
|
|
109
|
-
path.dirname(path.basename(filePath)) === "src" &&
|
|
110
|
-
path.basename(filePath) === "index.ts"),
|
|
111
|
-
}).onChange({ delay: 100 }, async (changeInfos) => {
|
|
112
|
-
const modifiedFileSet = this._getModifiedFileSet(changeInfos, lastWatchFileSet);
|
|
113
|
-
|
|
114
|
-
if (modifiedFileSet.size < 1) return;
|
|
115
|
-
|
|
116
|
-
this.emit("change");
|
|
117
|
-
|
|
118
|
-
let watchResult: IBuildRunnerRunResult;
|
|
119
|
-
try {
|
|
120
|
-
watchResult = await this._runAsync(
|
|
121
|
-
!this._pkgConf.forceProductionMode,
|
|
122
|
-
this._emitOnly,
|
|
123
|
-
this._noEmit,
|
|
124
|
-
modifiedFileSet,
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
lastWatchFileSet = watchResult.watchFileSet;
|
|
128
|
-
} catch (err) {
|
|
129
|
-
watchResult = {
|
|
130
|
-
affectedFileSet: modifiedFileSet,
|
|
131
|
-
buildMessages: [
|
|
132
|
-
{
|
|
133
|
-
filePath: undefined,
|
|
134
|
-
line: undefined,
|
|
135
|
-
char: undefined,
|
|
136
|
-
code: undefined,
|
|
137
|
-
severity: "error",
|
|
138
|
-
message: `파일 변경 처리 중 오류 발생: ${err}`,
|
|
139
|
-
type: "watch",
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
emitFileSet: new Set(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
101
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
102
|
+
let lastWatchFileSet = result.watchFileSet;
|
|
103
|
+
SdFsWatcher.watch(this._watchScopePathSet.toArray()).onChange(
|
|
104
|
+
{ delay: 300 },
|
|
105
|
+
async (changeInfos) => {
|
|
106
|
+
const modifiedFileSet = this._getModifiedFileSet(changeInfos, lastWatchFileSet);
|
|
107
|
+
|
|
108
|
+
if (modifiedFileSet.size < 1) return;
|
|
109
|
+
|
|
110
|
+
this.emit("change");
|
|
111
|
+
|
|
112
|
+
let watchResult: IBuildRunnerRunResult;
|
|
113
|
+
try {
|
|
114
|
+
watchResult = await this._runAsync(
|
|
115
|
+
!this._pkgConf.forceProductionMode,
|
|
116
|
+
this._emitOnly,
|
|
117
|
+
this._noEmit,
|
|
118
|
+
modifiedFileSet,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
lastWatchFileSet = watchResult.watchFileSet;
|
|
122
|
+
} catch (err) {
|
|
123
|
+
watchResult = {
|
|
124
|
+
affectedFileSet: modifiedFileSet,
|
|
125
|
+
buildMessages: [
|
|
126
|
+
{
|
|
127
|
+
filePath: undefined,
|
|
128
|
+
line: undefined,
|
|
129
|
+
char: undefined,
|
|
130
|
+
code: undefined,
|
|
131
|
+
severity: "error",
|
|
132
|
+
message: `파일 변경 처리 중 오류 발생: ${err}`,
|
|
133
|
+
type: "watch",
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
emitFileSet: new Set(),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.emit("complete", {
|
|
141
|
+
affectedFilePathSet: watchResult.affectedFileSet,
|
|
142
|
+
buildMessages: watchResult.buildMessages,
|
|
143
|
+
emitFileSet: watchResult.emitFileSet,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
);
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
protected _getModifiedFileSet(
|
|
155
150
|
changeInfos: ISdFsWatcherChangeInfo[],
|
|
156
151
|
lastWatchFileSet?: Set<TNormPath>,
|
|
157
152
|
) {
|
|
153
|
+
let arr: TNormPath[];
|
|
158
154
|
if (!lastWatchFileSet) {
|
|
159
|
-
|
|
155
|
+
arr = changeInfos.map((item) => item.path);
|
|
160
156
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
item.path.startsWith(path.dirname(item1)),
|
|
167
|
-
) ||
|
|
168
|
-
((this._pkgConf.type === "client" ||
|
|
169
|
-
(this._pkgConf.type === "library" && this._pkgConf.dbContext != null) ||
|
|
170
|
-
(this._pkgConf.type === "library" && this._pkgConf.noGenIndex)) &&
|
|
171
|
-
item.path.startsWith(path.resolve(this._pkgPath, "src")) &&
|
|
172
|
-
item.path.endsWith(".ts") &&
|
|
173
|
-
item.event === "add"),
|
|
174
|
-
)
|
|
175
|
-
.map((item) => item.path),
|
|
176
|
-
);
|
|
157
|
+
arr = changeInfos
|
|
158
|
+
.filter((item) =>
|
|
159
|
+
Array.from(lastWatchFileSet).some((item1) => item.path.startsWith(path.dirname(item1))),
|
|
160
|
+
)
|
|
161
|
+
.map((item) => item.path);
|
|
177
162
|
}
|
|
163
|
+
|
|
164
|
+
return new Set(arr);
|
|
178
165
|
}
|
|
179
166
|
|
|
180
167
|
protected abstract _runAsync(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FsUtils, HashUtils, PathUtils } from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtils, HashUtils, PathUtils, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { StringUtils } from "@simplysm/sd-core-common";
|
|
4
4
|
import { INpmConfig } from "../../types/common-configs.types";
|
|
@@ -6,16 +6,21 @@ import { INpmConfig } from "../../types/common-configs.types";
|
|
|
6
6
|
export class SdCliDbContextFileGenerator {
|
|
7
7
|
cachedHash?: string;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
watch(pkgPath: string, kebabName: string) {
|
|
10
10
|
const targetFilePath = path.resolve(pkgPath, `src/${kebabName}.ts`);
|
|
11
|
-
this.cachedHash = FsUtils.exists(targetFilePath)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
this.cachedHash = FsUtils.exists(targetFilePath)
|
|
12
|
+
? HashUtils.get(FsUtils.readFile(targetFilePath))
|
|
13
|
+
: undefined;
|
|
14
|
+
|
|
15
|
+
SdFsWatcher.watch([path.resolve(pkgPath, "src")], {
|
|
16
|
+
ignored: [targetFilePath],
|
|
17
|
+
}).onChange({ delay: 50 }, (changeInfos) => {
|
|
18
|
+
if (changeInfos.some((item) => ["add", "addDir", "unlink", "unlinkDir"].includes(item.event)))
|
|
19
|
+
this.run(pkgPath, kebabName);
|
|
15
20
|
});
|
|
16
21
|
|
|
17
22
|
this.run(pkgPath, kebabName);
|
|
18
|
-
}
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
run(pkgPath: string, kebabName: string): { changed: boolean; filePath: string; content: string } {
|
|
21
26
|
const npmConfig = FsUtils.readJson(path.resolve(pkgPath, "package.json")) as INpmConfig;
|
|
@@ -68,7 +73,14 @@ export class SdCliDbContextFileGenerator {
|
|
|
68
73
|
importTexts.push(`import { ${className} } from "./${requirePath}";`);
|
|
69
74
|
if (
|
|
70
75
|
useExt &&
|
|
71
|
-
[
|
|
76
|
+
[
|
|
77
|
+
"systemDataLog",
|
|
78
|
+
"systemLog",
|
|
79
|
+
"authentication",
|
|
80
|
+
"user",
|
|
81
|
+
"userConfig",
|
|
82
|
+
"userPermission",
|
|
83
|
+
].includes(varName)
|
|
72
84
|
) {
|
|
73
85
|
modelTexts.push(`override ${varName} = new Queryable(this, ${className})`);
|
|
74
86
|
} else {
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import { FsUtils, HashUtils, PathUtils } from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtils, HashUtils, PathUtils, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
export class SdCliIndexFileGenerator {
|
|
5
5
|
cachedHash?: string;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
watch(pkgPath: string, polyfills?: string[]) {
|
|
8
8
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
9
|
-
this.cachedHash = FsUtils.exists(indexFilePath)
|
|
9
|
+
this.cachedHash = FsUtils.exists(indexFilePath)
|
|
10
|
+
? HashUtils.get(FsUtils.readFile(indexFilePath))
|
|
11
|
+
: undefined;
|
|
10
12
|
|
|
11
|
-
SdFsWatcher.watch([path.resolve(pkgPath, "src")]
|
|
12
|
-
|
|
13
|
+
SdFsWatcher.watch([path.resolve(pkgPath, "src")], {
|
|
14
|
+
ignored: [indexFilePath],
|
|
15
|
+
}).onChange({ delay: 50 }, (changeInfos) => {
|
|
16
|
+
if (changeInfos.some((item) => ["add", "addDir", "unlink", "unlinkDir"].includes(item.event)))
|
|
17
|
+
this.run(pkgPath, polyfills);
|
|
13
18
|
});
|
|
14
19
|
|
|
15
20
|
this.run(pkgPath, polyfills);
|
|
16
|
-
}
|
|
21
|
+
}
|
|
17
22
|
|
|
18
|
-
run(
|
|
23
|
+
run(
|
|
24
|
+
pkgPath: string,
|
|
25
|
+
polyfills?: string[],
|
|
26
|
+
): { changed: boolean; filePath: string; content: string } {
|
|
19
27
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
20
28
|
|
|
21
29
|
const importTexts: string[] = [];
|
|
@@ -57,11 +65,14 @@ export class SdCliIndexFileGenerator {
|
|
|
57
65
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
58
66
|
|
|
59
67
|
const tsconfig = FsUtils.readJson(path.resolve(pkgPath, "tsconfig.json"));
|
|
60
|
-
const entryFilePaths: string[] =
|
|
68
|
+
const entryFilePaths: string[] =
|
|
69
|
+
tsconfig.files?.map((item) => path.resolve(pkgPath, item)) ?? [];
|
|
61
70
|
|
|
62
71
|
return FsUtils.glob(path.resolve(pkgPath, "src/**/*{.ts,.tsx}"), {
|
|
63
72
|
nodir: true,
|
|
64
73
|
ignore: tsconfig.excludes,
|
|
65
|
-
}).filter(
|
|
74
|
+
}).filter(
|
|
75
|
+
(item) => !entryFilePaths.includes(item) && item !== indexFilePath && !item.endsWith(".d.ts"),
|
|
76
|
+
);
|
|
66
77
|
}
|
|
67
78
|
}
|
|
@@ -7,41 +7,28 @@ import { SdCliDbContextFileGenerator } from "./sd-cli-db-context.file-generator"
|
|
|
7
7
|
export class SdTsLibBuildRunner extends BuildRunnerBase<"library"> {
|
|
8
8
|
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsLibBuildRunner"]);
|
|
9
9
|
|
|
10
|
-
#indexFileGenerator = new SdCliIndexFileGenerator();
|
|
11
|
-
#dbContextGenerator = new SdCliDbContextFileGenerator();
|
|
12
10
|
#builder?: SdTsLibBuilder;
|
|
13
11
|
|
|
14
|
-
#hasGenIndexError = false;
|
|
15
|
-
#hasGenDbContextError = false;
|
|
16
|
-
|
|
17
12
|
protected override async _runAsync(
|
|
18
13
|
dev: boolean,
|
|
19
14
|
emitOnly: boolean,
|
|
20
15
|
noEmit: boolean,
|
|
21
16
|
modifiedFileSet?: Set<TNormPath>,
|
|
22
17
|
): Promise<IBuildRunnerRunResult> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
modifiedFileSet.add(PathUtils.norm(genIndexResult.filePath));
|
|
18
|
+
// 최초한번
|
|
19
|
+
if (!modifiedFileSet) {
|
|
20
|
+
if (!noEmit) {
|
|
21
|
+
// index
|
|
22
|
+
if (!this._pkgConf.noGenIndex) {
|
|
23
|
+
this._debug("GEN index.ts...");
|
|
24
|
+
new SdCliIndexFileGenerator().watch(this._pkgPath, this._pkgConf.polyfills);
|
|
31
25
|
}
|
|
32
|
-
indexFileNPath = PathUtils.norm(genIndexResult.filePath);
|
|
33
|
-
}
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this._pkgPath,
|
|
39
|
-
this._pkgConf.dbContext,
|
|
40
|
-
);
|
|
41
|
-
if (modifiedFileSet && (genDbContextResult.changed || this.#hasGenDbContextError)) {
|
|
42
|
-
modifiedFileSet.add(PathUtils.norm(genDbContextResult.filePath));
|
|
27
|
+
// db-context
|
|
28
|
+
if (this._pkgConf.dbContext != null) {
|
|
29
|
+
this._debug(`GEN ${this._pkgConf.dbContext}.ts...`);
|
|
30
|
+
new SdCliDbContextFileGenerator().watch(this._pkgPath, this._pkgConf.dbContext);
|
|
43
31
|
}
|
|
44
|
-
dbContentFileNPath = PathUtils.norm(genDbContextResult.filePath);
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
34
|
|
|
@@ -55,13 +42,6 @@ export class SdTsLibBuildRunner extends BuildRunnerBase<"library"> {
|
|
|
55
42
|
);
|
|
56
43
|
const buildResult = await this.#builder.buildAsync(modifiedFileSet ?? new Set());
|
|
57
44
|
|
|
58
|
-
this.#hasGenIndexError =
|
|
59
|
-
indexFileNPath != null &&
|
|
60
|
-
buildResult.results.map((item) => item.filePath).includes(indexFileNPath);
|
|
61
|
-
this.#hasGenDbContextError =
|
|
62
|
-
dbContentFileNPath != null &&
|
|
63
|
-
buildResult.results.map((item) => item.filePath).includes(dbContentFileNPath);
|
|
64
|
-
|
|
65
45
|
this._debug(`빌드 완료`);
|
|
66
46
|
const watchFileSet = new Set(
|
|
67
47
|
Array.from(buildResult.watchFileSet).filter((item) => this._watchScopePathSet.inScope(item)),
|