-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathcheck_widgets.ts
More file actions
46 lines (38 loc) · 1.36 KB
/
check_widgets.ts
File metadata and controls
46 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
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
/* eslint-disable no-console */
/**
* Build-time check to ensure widget files exist
* This script validates that all registered widgets have corresponding files
*/
import { existsSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { WIDGET_REGISTRY } from '../src/resources/widgets.js';
const filename = fileURLToPath(import.meta.url);
const projectRoot = resolve(dirname(filename), '..');
const webDistPath = resolve(projectRoot, 'src/web/dist');
const missingWidgets: string[] = [];
const existingWidgets: string[] = [];
for (const config of Object.values(WIDGET_REGISTRY)) {
const jsPath = resolve(webDistPath, config.jsFilename);
if (existsSync(jsPath)) {
existingWidgets.push(config.name);
} else {
missingWidgets.push(`${config.name} (${config.jsFilename})`);
}
}
if (missingWidgets.length > 0) {
console.error('Missing widget files:');
for (const widget of missingWidgets) {
console.error(` - ${widget}`);
}
console.error(`\nExpected location: ${webDistPath}`);
console.error('\nPlease build the widgets before building the server.');
process.exit(1);
}
if (existingWidgets.length > 0) {
console.log('All widget files found:');
for (const widget of existingWidgets) {
console.log(` - ${widget}`);
}
}
process.exit(0);