adminforth 1.0.15 β 1.0.17
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/modules/codeInjector.js +20 -7
- package/package.json +1 -1
package/modules/codeInjector.js
CHANGED
|
@@ -132,7 +132,7 @@ class CodeInjector {
|
|
|
132
132
|
|
|
133
133
|
// copy whole custom directory
|
|
134
134
|
if (this.adminforth.config.customization?.customComponentsDir) {
|
|
135
|
-
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(
|
|
135
|
+
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom'), {
|
|
136
136
|
recursive: true,
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -246,7 +246,7 @@ class CodeInjector {
|
|
|
246
246
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
async watchForReprepare({ verbose }) {
|
|
250
250
|
const spaPath = path.join(__dirname, 'spa');
|
|
251
251
|
// get list of all subdirectories in spa recursively
|
|
252
252
|
const directories = [];
|
|
@@ -261,7 +261,10 @@ class CodeInjector {
|
|
|
261
261
|
};
|
|
262
262
|
await collectDirectories(spaPath);
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
if (verbose) {
|
|
265
|
+
console.log('π Watching for changes in:', directories.join(','));
|
|
266
|
+
}
|
|
267
|
+
|
|
265
268
|
|
|
266
269
|
const watcher = filewatcher();
|
|
267
270
|
directories.forEach((dir) => {
|
|
@@ -280,13 +283,16 @@ class CodeInjector {
|
|
|
280
283
|
});
|
|
281
284
|
}
|
|
282
285
|
|
|
283
|
-
async watchCustomComponentsForCopy() {
|
|
286
|
+
async watchCustomComponentsForCopy({ verbose }) {
|
|
284
287
|
const customComponentsDir = this.adminforth.config.customization.customComponentsDir;
|
|
285
288
|
|
|
286
289
|
// check if folder exists
|
|
287
290
|
try {
|
|
288
291
|
await fs.promises.access(customComponentsDir, fs.constants.F_OK);
|
|
289
292
|
} catch (e) {
|
|
293
|
+
if (verbose) {
|
|
294
|
+
console.log(`Custom components dir ${customComponentsDir} does not exist, skipping watching`);
|
|
295
|
+
}
|
|
290
296
|
return;
|
|
291
297
|
}
|
|
292
298
|
|
|
@@ -310,12 +316,19 @@ class CodeInjector {
|
|
|
310
316
|
watcher.add(dir);
|
|
311
317
|
});
|
|
312
318
|
|
|
319
|
+
if (verbose) {
|
|
320
|
+
console.log('π Watching for changes in:', directories.join(','));
|
|
321
|
+
}
|
|
322
|
+
|
|
313
323
|
watcher.on(
|
|
314
324
|
'change',
|
|
315
325
|
async (file) => {
|
|
316
326
|
// copy one file
|
|
317
327
|
// TODO: non optimal, copy only changed file, test on both nested and parent dir
|
|
318
|
-
|
|
328
|
+
if (verbose) {
|
|
329
|
+
console.log(`π File ${file} changed, copying to spa_tmp...`);
|
|
330
|
+
}
|
|
331
|
+
await fsExtra.copy(this.adminforth.config.customization.customComponentsDir, path.join(CodeInjector.SPA_TMP_PATH, 'src', 'custom'), {
|
|
319
332
|
recursive: true,
|
|
320
333
|
});
|
|
321
334
|
}
|
|
@@ -331,8 +344,8 @@ class CodeInjector {
|
|
|
331
344
|
await this.prepareSources({ verbose });
|
|
332
345
|
|
|
333
346
|
if (hotReload) {
|
|
334
|
-
await this.watchForReprepare();
|
|
335
|
-
await this.watchCustomComponentsForCopy();
|
|
347
|
+
await this.watchForReprepare({ verbose });
|
|
348
|
+
await this.watchCustomComponentsForCopy({ verbose });
|
|
336
349
|
}
|
|
337
350
|
|
|
338
351
|
console.log('AdminForth bundling');
|