웹타입 컴포넌트 분리작업
This commit is contained in:
87
replace-selects.js
Normal file
87
replace-selects.js
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 교체할 패턴들
|
||||
const patterns = [
|
||||
// 기본 Select 패턴
|
||||
{
|
||||
from: /<Select\s+([^>]*?)>\s*<SelectTrigger([^>]*?)>\s*<SelectValue([^>]*?)\/>\s*<\/SelectTrigger>\s*<SelectContent>([\s\S]*?)<\/SelectContent>\s*<\/Select>/g,
|
||||
to: (match, selectProps, triggerProps, valueProps, content) => {
|
||||
// SelectItem들을 option으로 변환
|
||||
const options = content.replace(/<SelectItem\s+([^>]*?)>([\s\S]*?)<\/SelectItem>/g, (itemMatch, itemProps, itemContent) => {
|
||||
const valueMatch = itemProps.match(/value="([^"]*?)"/);
|
||||
const value = valueMatch ? valueMatch[1] : '';
|
||||
return `<option value="${value}">${itemContent.trim()}</option>`;
|
||||
});
|
||||
|
||||
// className 추출
|
||||
const classMatch = triggerProps.match(/className="([^"]*?)"/);
|
||||
const triggerClass = classMatch ? classMatch[1] : '';
|
||||
|
||||
// value와 onValueChange 추출
|
||||
const valueMatch = selectProps.match(/value=\{([^}]*?)\}/);
|
||||
const onChangeMatch = selectProps.match(/onValueChange=\{([^}]*?)\}/);
|
||||
|
||||
const value = valueMatch ? valueMatch[1] : '';
|
||||
const onChange = onChangeMatch ? onChangeMatch[1] : '';
|
||||
|
||||
// onChange를 HTML select 형식으로 변환
|
||||
const htmlOnChange = onChange.replace(/\(([^)]*?)\)\s*=>\s*/, '(e) => ').replace(/value/g, 'e.target.value');
|
||||
|
||||
return `<select
|
||||
className="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none ${triggerClass}"
|
||||
value={${value}}
|
||||
onChange={${htmlOnChange}}
|
||||
>
|
||||
${options}
|
||||
</select>`;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// 파일 처리 함수
|
||||
function processFile(filePath) {
|
||||
try {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let modified = false;
|
||||
|
||||
patterns.forEach(pattern => {
|
||||
if (pattern.from.test(content)) {
|
||||
content = content.replace(pattern.from, pattern.to);
|
||||
modified = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(filePath, content, 'utf8');
|
||||
console.log(`✅ 수정됨: ${filePath}`);
|
||||
} else {
|
||||
console.log(`⏭️ 변경사항 없음: ${filePath}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ 오류 (${filePath}):`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 처리할 파일들
|
||||
const filesToProcess = [
|
||||
'frontend/components/screen/panels/PropertiesPanel.tsx',
|
||||
'frontend/components/screen/panels/DataTableConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/ButtonConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/FileComponentConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/ResolutionPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/TextTypeConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/NumberTypeConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/DateTypeConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/CheckboxTypeConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/EntityTypeConfigPanel.tsx',
|
||||
'frontend/components/screen/panels/webtype-configs/CodeTypeConfigPanel.tsx',
|
||||
];
|
||||
|
||||
console.log('🔄 Select 컴포넌트 교체 시작...');
|
||||
filesToProcess.forEach(processFile);
|
||||
console.log('✅ 완료!');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user