Files
u-claw/portable/migrate.js
dongsheng123132 6c1bff5572 feat: v1.1 portable architecture (app/data separation)
New directory structure:
- app/core/ = OpenClaw program
- app/runtime/ = Node.js
- data/ = user config, memory, backups (never overwritten on upgrade)
- system/ = migration scripts

Features:
- Auto port detection (18789-18799)
- macOS Gatekeeper auto-fix (xattr quarantine removal)
- Windows UTF-8 BOM + CRLF encoding
- Config auto-migration on startup
- Platform-specific packages (Mac ARM64 + Windows x64)
2026-03-10 22:10:28 +08:00

34 lines
982 B
JavaScript

#!/usr/bin/env node
// U-Claw config migration script
// Runs on every startup to ensure config compatibility
const fs = require('fs');
const path = require('path');
const dataDir = process.argv[2] || path.join(__dirname, '..', 'data');
const configPath = path.join(dataDir, 'config.json');
if (!fs.existsSync(configPath)) process.exit(0);
try {
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
// Ensure gateway section exists
if (!config.gateway) {
config.gateway = { mode: 'local', auth: { token: 'uclaw' } };
}
// Ensure auth token exists
if (!config.gateway.auth || !config.gateway.auth.token) {
config.gateway.auth = { token: 'uclaw' };
}
// Future migrations go here:
// if (!config._version) { config._version = '1.1'; ... }
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
} catch (e) {
// Don't crash on migration errors
console.error('Migration warning:', e.message);
}