Browse Source
- Remove deprecated $updateSettings method entirely - Migrate 21 components to use proper settings methods - Consolidate IPlatformServiceMixin and ComponentCustomProperties interfaces - Establish single source of truth for platform service methods - Update all components to use $saveMySettings, $saveUserSettings, $saveSettings - Remove interface duplication and deprecated method warnings - Ensure clean, maintainable codebase with proper separation of concerns Breaking Change: $updateSettings method removed - use $saveSettings variants insteadpull/166/head
15 changed files with 221 additions and 177 deletions
@ -0,0 +1,28 @@ |
|||
#!/bin/bash |
|||
|
|||
# CI check script to ensure no new $updateSettings usage is introduced |
|||
# This script will fail CI if any $updateSettings calls are found |
|||
|
|||
set -e |
|||
|
|||
echo "🔍 Checking for deprecated \$updateSettings usage..." |
|||
|
|||
# Search for $updateSettings usage in source files |
|||
USAGE_COUNT=$(grep -r "\$updateSettings" src/ --include="*.vue" --include="*.ts" --include="*.js" | wc -l) |
|||
|
|||
if [ "$USAGE_COUNT" -gt 0 ]; then |
|||
echo "❌ Found $USAGE_COUNT usage(s) of deprecated \$updateSettings method:" |
|||
echo "" |
|||
grep -r "\$updateSettings" src/ --include="*.vue" --include="*.ts" --include="*.js" -n |
|||
echo "" |
|||
echo "⚠️ Migration required:" |
|||
echo " - For global settings: use \$saveSettings(changes)" |
|||
echo " - For user-specific settings: use \$saveUserSettings(did, changes)" |
|||
echo " - For current user settings: use \$saveMySettings(changes)" |
|||
echo "" |
|||
echo "Run 'node scripts/migrate-update-settings.js' for migration guidance." |
|||
exit 1 |
|||
else |
|||
echo "✅ No \$updateSettings usage found!" |
|||
exit 0 |
|||
fi |
@ -0,0 +1,110 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
/** |
|||
* Migration script to replace deprecated $updateSettings calls |
|||
* with the appropriate new methods ($saveSettings, $saveUserSettings, $saveMySettings) |
|||
* |
|||
* Usage: node scripts/migrate-update-settings.js |
|||
* |
|||
* This script will: |
|||
* 1. Find all files containing $updateSettings calls |
|||
* 2. Show the migration suggestions for each call |
|||
* 3. Optionally perform the replacements |
|||
*/ |
|||
|
|||
const fs = require('fs'); |
|||
const path = require('path'); |
|||
const glob = require('glob'); |
|||
|
|||
// Migration patterns
|
|||
const MIGRATION_PATTERNS = [ |
|||
{ |
|||
pattern: /\$updateSettings\(\s*(\{[^}]*\})\s*\)/g, |
|||
replacement: '$saveMySettings($1)', |
|||
description: 'Single parameter (changes only) -> $saveMySettings' |
|||
}, |
|||
{ |
|||
pattern: /\$updateSettings\(\s*(\{[^}]*\})\s*,\s*([^)]+)\s*\)/g, |
|||
replacement: '$saveUserSettings($2, $1)', |
|||
description: 'Two parameters (changes, did) -> $saveUserSettings(did, changes)' |
|||
} |
|||
]; |
|||
|
|||
// Find all Vue and TypeScript files
|
|||
function findFiles() { |
|||
const patterns = [ |
|||
'src/**/*.vue', |
|||
'src/**/*.ts', |
|||
'src/**/*.js' |
|||
]; |
|||
|
|||
let files = []; |
|||
patterns.forEach(pattern => { |
|||
files = files.concat(glob.sync(pattern, { ignore: ['node_modules/**', 'dist/**'] })); |
|||
}); |
|||
|
|||
return files; |
|||
} |
|||
|
|||
// Analyze a file for $updateSettings usage
|
|||
function analyzeFile(filePath) { |
|||
const content = fs.readFileSync(filePath, 'utf8'); |
|||
const lines = content.split('\n'); |
|||
const usages = []; |
|||
|
|||
lines.forEach((line, index) => { |
|||
if (line.includes('$updateSettings')) { |
|||
usages.push({ |
|||
line: index + 1, |
|||
content: line.trim(), |
|||
file: filePath |
|||
}); |
|||
console.log(`\n${filePath}:${index + 1}`); |
|||
console.log(` ${line.trim()}`); |
|||
|
|||
// Show migration suggestion
|
|||
MIGRATION_PATTERNS.forEach(pattern => { |
|||
if (pattern.pattern.test(line)) { |
|||
const replacement = line.replace(pattern.pattern, pattern.replacement); |
|||
console.log(` → ${replacement.trim()}`); |
|||
console.log(` ${pattern.description}`); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
return usages; |
|||
} |
|||
|
|||
// Main execution
|
|||
function main() { |
|||
console.log('🔍 Finding files with $updateSettings usage...\n'); |
|||
|
|||
const files = findFiles(); |
|||
let totalUsages = 0; |
|||
|
|||
files.forEach(file => { |
|||
const usages = analyzeFile(file); |
|||
totalUsages += usages.length; |
|||
}); |
|||
|
|||
console.log(`\n📊 Summary:`); |
|||
console.log(` Files scanned: ${files.length}`); |
|||
console.log(` Total usages: ${totalUsages}`); |
|||
|
|||
if (totalUsages > 0) { |
|||
console.log(`\n📝 Migration Guide:`); |
|||
console.log(` 1. For global/default settings: use $saveSettings(changes)`); |
|||
console.log(` 2. For user-specific settings: use $saveUserSettings(did, changes)`); |
|||
console.log(` 3. For current user settings: use $saveMySettings(changes)`); |
|||
console.log(`\n⚠️ Note: $updateSettings is deprecated and will be removed in a future version.`); |
|||
} else { |
|||
console.log(`\n✅ No $updateSettings usage found!`); |
|||
} |
|||
} |
|||
|
|||
if (require.main === module) { |
|||
main(); |
|||
} |
|||
|
|||
module.exports = { findFiles, analyzeFile, MIGRATION_PATTERNS }; |
Loading…
Reference in new issue