mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
chore: 清理 src 下 33 项死代码和类型断言
删除未使用的文件/目录(mcp/adapter、cli/update.ts 等)、 未使用的重导出文件(design-system/color.ts 等 12 个)、 7 个零引用的导出函数、修复 5 处 as any 为精确类型。 净减少 ~1194 行代码,precheck 4077 测试全部通过。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
import { logEvent } from 'src/services/analytics/index.js'
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js'
|
||||
import { logError } from '../utils/log.js'
|
||||
import {
|
||||
getSettingsForSource,
|
||||
updateSettingsForSource,
|
||||
} from '../utils/settings/settings.js'
|
||||
/**
|
||||
* Migration: Move user-set autoUpdates preference to settings.json env var
|
||||
* Only migrates if user explicitly disabled auto-updates (not for protection)
|
||||
* This preserves user intent while allowing native installations to auto-update
|
||||
*/
|
||||
export function migrateAutoUpdatesToSettings(): void {
|
||||
const globalConfig = getGlobalConfig()
|
||||
|
||||
// Only migrate if autoUpdates was explicitly set to false by user preference
|
||||
// (not automatically for native protection)
|
||||
if (
|
||||
globalConfig.autoUpdates !== false ||
|
||||
globalConfig.autoUpdatesProtectedForNative === true
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const userSettings = getSettingsForSource('userSettings') || {}
|
||||
|
||||
// Always set DISABLE_AUTOUPDATER to preserve user intent
|
||||
// We need to overwrite even if it exists, to ensure the migration is complete
|
||||
updateSettingsForSource('userSettings', {
|
||||
...userSettings,
|
||||
env: {
|
||||
...userSettings.env,
|
||||
DISABLE_AUTOUPDATER: '1',
|
||||
},
|
||||
})
|
||||
|
||||
logEvent('tengu_migrate_autoupdates_to_settings', {
|
||||
was_user_preference: true,
|
||||
already_had_env_var: !!userSettings.env?.DISABLE_AUTOUPDATER,
|
||||
})
|
||||
|
||||
// explicitly set, so this takes effect immediately
|
||||
process.env.DISABLE_AUTOUPDATER = '1'
|
||||
|
||||
// Remove autoUpdates from global config after successful migration
|
||||
saveGlobalConfig(current => {
|
||||
const {
|
||||
autoUpdates: _,
|
||||
autoUpdatesProtectedForNative: __,
|
||||
...updatedConfig
|
||||
} = current
|
||||
return updatedConfig
|
||||
})
|
||||
} catch (error) {
|
||||
logError(new Error(`Failed to migrate auto-updates: ${error}`))
|
||||
logEvent('tengu_migrate_autoupdates_error', {
|
||||
has_error: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user