mirror of
https://github.com/unraid/api.git
synced 2026-01-03 23:19:54 -06:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced Docker management UI components: Overview, Logs, Console, Preview, and Edit. - Added responsive Card/Detail layouts with grouping, bulk actions, and tabs. - New UnraidToaster component and global toaster configuration. - Component auto-mounting improved with async loading and multi-selector support. - UI/UX - Overhauled theme system (light/dark tokens, primary/orange accents) and added theme variants. - Header OS version now includes integrated changelog modal. - Registration displays warning states; multiple visual polish updates. - API - CPU load now includes percentGuest and percentSteal metrics. - Chores - Migrated web app to Vite; updated artifacts and manifests. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mdatelle <mike@datelle.net> Co-authored-by: Michael Datelle <mdatelle@icloud.com>
81 lines
2.3 KiB
JavaScript
Executable File
81 lines
2.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import { execSync } from 'child_process';
|
|
import { existsSync, statSync } from 'fs';
|
|
import { dirname, join } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const rootDir = join(__dirname, '..', '..');
|
|
const uiSrcDir = join(rootDir, 'unraid-ui', 'src');
|
|
const uiDistDir = join(rootDir, 'unraid-ui', 'dist');
|
|
const uiDistIndexFile = join(uiDistDir, 'index.js');
|
|
|
|
function getLatestModificationTime(dir) {
|
|
const result = execSync(
|
|
`find "${dir}" -type f -name "*.ts" -o -name "*.tsx" -o -name "*.vue" -o -name "*.css" | xargs stat -f "%m" 2>/dev/null | sort -rn | head -1 || echo 0`,
|
|
{
|
|
encoding: 'utf-8',
|
|
shell: true,
|
|
}
|
|
).trim();
|
|
|
|
return parseInt(result) || 0;
|
|
}
|
|
|
|
function shouldRebuild() {
|
|
// If dist doesn't exist, we need to build
|
|
if (!existsSync(uiDistIndexFile)) {
|
|
console.log('UI library dist not found, building...');
|
|
return true;
|
|
}
|
|
|
|
// Get the modification time of the dist index file
|
|
const distModTime = statSync(uiDistIndexFile).mtimeMs / 1000;
|
|
|
|
// Get the latest modification time from source files
|
|
const srcModTime = getLatestModificationTime(uiSrcDir);
|
|
|
|
// Also check package.json, vite.config.ts, etc.
|
|
const configFiles = [
|
|
join(rootDir, 'unraid-ui', 'package.json'),
|
|
join(rootDir, 'unraid-ui', 'vite.config.ts'),
|
|
join(rootDir, 'unraid-ui', 'tsconfig.json'),
|
|
];
|
|
|
|
let latestConfigModTime = 0;
|
|
for (const file of configFiles) {
|
|
if (existsSync(file)) {
|
|
const modTime = statSync(file).mtimeMs / 1000;
|
|
if (modTime > latestConfigModTime) {
|
|
latestConfigModTime = modTime;
|
|
}
|
|
}
|
|
}
|
|
|
|
const latestSrcTime = Math.max(srcModTime, latestConfigModTime);
|
|
|
|
if (latestSrcTime > distModTime) {
|
|
console.log('UI library source files changed, rebuilding...');
|
|
return true;
|
|
}
|
|
|
|
console.log('UI library is up to date, skipping build.');
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
if (shouldRebuild()) {
|
|
console.log('Building @unraid/ui...');
|
|
execSync('pnpm --filter=@unraid/ui build', {
|
|
stdio: 'inherit',
|
|
cwd: rootDir,
|
|
});
|
|
console.log('UI library build complete.');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error building UI library:', error.message);
|
|
process.exit(1);
|
|
}
|