Skip to content

Commit bf65e5d

Browse files
committed
Validation & Structure Improvements
1 parent 0b3b5a6 commit bf65e5d

File tree

8 files changed

+359
-106
lines changed

8 files changed

+359
-106
lines changed

CHANGELOG.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SQL2Excel Version History
22

3-
## v1.2.6 - Validation & Structure Improvements (2025-10-14)
3+
## v1.2.6 - Validation & Structure Improvements (2025-10-15)
44

55
### ✨ New Features
66
- **Sheet Name Validation**: Added Excel sheet name validation logic
@@ -17,8 +17,13 @@
1717

1818
- **Interactive Menu System**: User-friendly menu system in sql2db style
1919
- `app.js`: Multi-language menu system
20-
- `run.bat`: English version launcher script
21-
- `실행하기.bat`: Korean version launcher script
20+
- `run.bat`: English version launcher script (`--lang=en`)
21+
- `실행하기.bat`: Korean version launcher script (`--lang=kr`)
22+
23+
- **Multi-language Support**: Language selection via command line arguments
24+
- `--lang=en`: English interface
25+
- `--lang=kr`: Korean interface
26+
- Multi-language support for menus, messages, and errors
2227

2328
### 🔧 Technical Improvements
2429
- **Improved dbinfo.json Structure**: Removed dbs wrapper
@@ -30,10 +35,57 @@
3035
- `mssql-connection-manager.js`: Added pkg environment path handling
3136
- Unified all file paths based on APP_ROOT
3237

38+
- **pkg Build Optimization** (2025-10-15)
39+
- Removed `--no-native-build` option: Improved native module compatibility
40+
- Explicit native module inclusion: Added `mssql`, `tedious` to assets
41+
- Explicit entry point: Specified as `pkg app.js` format
42+
- Explicit target: Specified `--target node18-win-x64`
43+
- Added compression: Optimized file size with `--compress GZip`
44+
45+
- **pkg Environment Support** (2025-10-15)
46+
- Detect pkg environment and call modules directly in `app.js`
47+
- Directly require `excel-cli.js` module for functionality
48+
- Automatic branching between Node.js and pkg environments
49+
- Dynamic reconstruction of `process.argv` for module calls
50+
- `excel-cli.js`: Dynamically read args and command within main() function
51+
- `file-utils.js`: APP_ROOT-based path handling (pkg environment support)
52+
- `index.js`: Create new yargs instance each time with explicit process.argv
53+
54+
- **Improved Option Parsing** (2025-10-15)
55+
- Added `--lang` option handling in `excel-cli.js`
56+
- Added unknown option ignore functionality (`default` case)
57+
- Enhanced option parser stability
58+
- Improved `yargs` usage: Changed to `require('yargs/yargs')`
59+
- Explicit `process.argv.slice(2)` passing for pkg environment compatibility
60+
3361
### 🐛 Bug Fixes
3462
- **queryDef validation error**: Improved id attribute recognition in queryDef
3563
- **Variable substitution sheet name validation**: Changed to validate after variable substitution
3664
- **validate command option parsing**: Improved --xml option recognition
65+
- **Fixed "i is not defined" error** (2025-10-15)
66+
- `index.js`: Added `sheetIndex` variable in for-of loop
67+
- Improved index tracking logic in sheet processing loop
68+
- Fixed passing correct index to sheet name validation function
69+
70+
- **Fixed sheet name validation not applied during file validation** (2025-10-15)
71+
- `excel-cli.js`: Moved sheet name validation logic outside queryDefs block
72+
- Improved structure to ensure validation always runs
73+
- Returns `false` with clear error messages on validation failure
74+
- Auto-correction during query execution, validation failure during file validation
75+
76+
### 🎨 UI/UX Improvements (2025-10-15)
77+
- **Detailed Validation Output**
78+
- Sheet list: Display full list instead of just count
79+
- Per-sheet validation results: Show ✅ success / ❌ failure for each
80+
- Detailed failure reasons: Specify which rules were violated
81+
- Database list: Display detailed info including server, DB name, user, permissions
82+
83+
### 📦 Distribution Improvements (2025-10-15)
84+
- **Auto-generate Batch Files**: Generate language-specific batch files in `create-release.js`
85+
- `run.bat`: Automatically includes `--lang=en`
86+
- `실행하기.bat`: Automatically includes `--lang=kr`
87+
- **Optimized Executable Size**: Reduced size by ~40% through compression
88+
- **Native Module Inclusion**: Guaranteed proper operation of DB connection libraries
3789

3890
## v1.2.5 - Batch Interface Improvements (2025-10-10)
3991

CHANGELOG_KR.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SQL2Excel 버전 히스토리
22

3-
## v1.2.6 - 검증 및 구조 개선 (2025-10-14)
3+
## v1.2.6 - 검증 및 구조 개선 (2025-10-15)
44

55
### ✨ 새로운 기능
66
- **시트명 검증**: Excel 시트명 유효성 검증 로직 추가
@@ -17,8 +17,13 @@
1717

1818
- **인터랙티브 메뉴 시스템**: sql2db 스타일의 사용자 친화적 메뉴
1919
- `app.js`: 다국어 지원 메뉴 시스템
20-
- `run.bat`: 영어 버전 실행 스크립트
21-
- `실행하기.bat`: 한글 버전 실행 스크립트
20+
- `run.bat`: 영어 버전 실행 스크립트 (`--lang=en`)
21+
- `실행하기.bat`: 한글 버전 실행 스크립트 (`--lang=kr`)
22+
23+
- **다국어 지원**: 명령줄 인수를 통한 언어 선택
24+
- `--lang=en`: 영문 인터페이스
25+
- `--lang=kr`: 한글 인터페이스
26+
- 메뉴, 메시지, 에러 모두 다국어 지원
2227

2328
### 🔧 기술적 개선
2429
- **dbinfo.json 구조 개선**: dbs 래퍼 제거
@@ -30,10 +35,57 @@
3035
- `mssql-connection-manager.js`: pkg 환경 경로 처리 추가
3136
- 모든 파일 경로를 APP_ROOT 기준으로 통일
3237

38+
- **pkg 빌드 최적화** (2025-10-15)
39+
- `--no-native-build` 옵션 제거: 네이티브 모듈 호환성 개선
40+
- 네이티브 모듈 명시적 포함: `mssql`, `tedious` assets 추가
41+
- 진입점 명시: `pkg app.js` 형태로 명확한 진입점 지정
42+
- Target 명시: `--target node18-win-x64` 명시적 지정
43+
- 압축 추가: `--compress GZip`로 파일 크기 최적화
44+
45+
- **pkg 환경 지원** (2025-10-15)
46+
- `app.js`에서 pkg 환경 감지 및 모듈 직접 호출
47+
- `excel-cli.js` 모듈 직접 require하여 기능 실행
48+
- Node.js 환경과 pkg 환경 자동 분기 처리
49+
- `process.argv` 동적 재구성으로 모듈 호출
50+
- `excel-cli.js`: args와 command를 main() 함수 내에서 동적 읽기
51+
- `file-utils.js`: APP_ROOT 기반 경로 처리 (pkg 환경 지원)
52+
- `index.js`: yargs를 매번 새로 생성하여 process.argv 명시적 전달
53+
54+
- **옵션 파싱 개선** (2025-10-15)
55+
- `excel-cli.js``--lang` 옵션 처리 추가
56+
- 알 수 없는 옵션 무시 기능 추가 (`default` case)
57+
- 옵션 파서 안정성 향상
58+
- `yargs` 사용 방식 개선: `require('yargs/yargs')`로 변경
59+
- `process.argv.slice(2)` 명시적 전달로 pkg 환경 호환성 확보
60+
3361
### 🐛 버그 수정
3462
- **queryDef 검증 오류**: queryDef의 id 속성 인식 개선
3563
- **변수 치환 시트명 검증**: 변수 치환 후 시트명 검증으로 변경
3664
- **validate 명령 옵션 파싱**: --xml 옵션 인식 개선
65+
- **"i is not defined" 에러 수정** (2025-10-15)
66+
- `index.js`: for-of 루프에서 `sheetIndex` 변수 추가
67+
- 시트 처리 루프에서 인덱스 추적 로직 개선
68+
- 시트명 검증 함수 호출 시 올바른 인덱스 전달
69+
70+
- **파일 검증 시 시트명 검증 미적용 문제 수정** (2025-10-15)
71+
- `excel-cli.js`: 시트명 검증 로직을 queryDefs 블록 밖으로 이동
72+
- 검증이 항상 실행되도록 구조 개선
73+
- 검증 실패 시 명확한 에러 메시지와 함께 `false` 반환
74+
- 쿼리 실행 시에는 자동 수정, 파일 검증 시에는 검증 실패 처리
75+
76+
### 🎨 UI/UX 개선 (2025-10-15)
77+
- **검증 결과 상세 출력**
78+
- 시트 목록: 개수만이 아닌 전체 목록 출력
79+
- 각 시트별 검증 결과: ✅ 성공 / ❌ 실패 표시
80+
- 실패 원인 상세 설명: 어떤 규칙을 위반했는지 명시
81+
- 데이터베이스 목록: 서버, DB명, 사용자, 권한 등 상세 정보 표시
82+
83+
### 📦 배포판 개선 (2025-10-15)
84+
- **배치 파일 자동 생성**: `create-release.js`에서 언어별 배치 파일 생성
85+
- `run.bat`: `--lang=en` 자동 포함
86+
- `실행하기.bat`: `--lang=kr` 자동 포함
87+
- **실행 파일 크기 최적화**: 압축으로 약 40% 크기 감소
88+
- **네이티브 모듈 포함**: DB 연결 라이브러리 정상 작동 보장
3789

3890
## v1.2.5 - 배치 인터페이스 개선 (2025-10-10)
3991

app.js

Lines changed: 105 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const { execSync } = require('child_process');
66
// pkg 실행 파일 경로 처리
77
const APP_ROOT = process.pkg ? path.dirname(process.execPath) : __dirname;
88

9+
// pkg 환경에서 excel-cli 모듈 직접 로드
10+
const excelCli = process.pkg ? require('./src/excel-cli') : null;
11+
912
// ANSI 색상 코드
1013
const colors = {
1114
reset: '\x1b[0m',
@@ -276,15 +279,36 @@ async function validateQuery() {
276279
console.log();
277280

278281
try {
279-
const command = file.type === 'XML'
280-
? `node src/excel-cli.js validate --xml "${file.path}"`
281-
: `node src/excel-cli.js validate --query "${file.path}"`;
282-
283-
execSync(command, {
284-
cwd: APP_ROOT,
285-
stdio: 'inherit',
286-
encoding: 'utf8'
287-
});
282+
if (process.pkg) {
283+
// pkg 환경: 직접 모듈 사용
284+
const options = {
285+
configFilePath: path.join(APP_ROOT, 'config', 'dbinfo.json'),
286+
variables: {}
287+
};
288+
289+
if (file.type === 'XML') {
290+
options.xmlFilePath = file.path;
291+
} else {
292+
options.queryFilePath = file.path;
293+
}
294+
295+
const isValid = await excelCli.validateQueryFile(options);
296+
297+
if (!isValid) {
298+
throw new Error('Validation failed');
299+
}
300+
} else {
301+
// Node.js 환경: CLI 실행
302+
const command = file.type === 'XML'
303+
? `node src/excel-cli.js validate --xml "${file.path}"`
304+
: `node src/excel-cli.js validate --query "${file.path}"`;
305+
306+
execSync(command, {
307+
cwd: APP_ROOT,
308+
stdio: 'inherit',
309+
encoding: 'utf8'
310+
});
311+
}
288312

289313
console.log();
290314
console.log(colors.green + ` ${msg.validationCompleted}` + colors.reset);
@@ -309,11 +333,18 @@ async function testConnection() {
309333
console.log();
310334

311335
try {
312-
execSync('node src/excel-cli.js list-dbs', {
313-
cwd: APP_ROOT,
314-
stdio: 'inherit',
315-
encoding: 'utf8'
316-
});
336+
if (process.pkg) {
337+
// pkg 환경: 직접 모듈 사용
338+
const configPath = path.join(APP_ROOT, 'config', 'dbinfo.json');
339+
await excelCli.testAllDatabaseConnections(configPath);
340+
} else {
341+
// Node.js 환경: CLI 실행
342+
execSync('node src/excel-cli.js list-dbs', {
343+
cwd: APP_ROOT,
344+
stdio: 'inherit',
345+
encoding: 'utf8'
346+
});
347+
}
317348

318349
console.log();
319350
console.log(colors.green + ` ${msg.connectionSuccess}` + colors.reset);
@@ -372,11 +403,36 @@ async function exportExcelXML() {
372403
const startTime = new Date();
373404

374405
try {
375-
execSync(`node src/excel-cli.js export --xml "${selectedFile.path}"`, {
376-
cwd: APP_ROOT,
377-
stdio: 'inherit',
378-
encoding: 'utf8'
379-
});
406+
if (process.pkg) {
407+
// pkg 환경: 직접 모듈 사용
408+
const originalArgv = process.argv;
409+
const originalExit = process.exit;
410+
411+
// process.exit를 무효화하여 프로그램이 종료되지 않도록 함
412+
process.exit = (code) => {
413+
if (code !== 0) {
414+
throw new Error(`Process exited with code ${code}`);
415+
}
416+
};
417+
418+
// --lang 옵션을 제외하고 재구성
419+
const filteredArgs = originalArgv.slice(2).filter(arg => !arg.startsWith('--lang='));
420+
process.argv = ['node', 'src/excel-cli.js', 'export', '--xml', selectedFile.path, ...filteredArgs];
421+
422+
try {
423+
await excelCli.main();
424+
} finally {
425+
process.argv = originalArgv;
426+
process.exit = originalExit;
427+
}
428+
} else {
429+
// Node.js 환경: CLI 실행
430+
execSync(`node src/excel-cli.js export --xml "${selectedFile.path}"`, {
431+
cwd: APP_ROOT,
432+
stdio: 'inherit',
433+
encoding: 'utf8'
434+
});
435+
}
380436

381437
const endTime = new Date();
382438

@@ -438,11 +494,36 @@ async function exportExcelJSON() {
438494
const startTime = new Date();
439495

440496
try {
441-
execSync(`node src/excel-cli.js export --query "${selectedFile.path}"`, {
442-
cwd: APP_ROOT,
443-
stdio: 'inherit',
444-
encoding: 'utf8'
445-
});
497+
if (process.pkg) {
498+
// pkg 환경: 직접 모듈 사용
499+
const originalArgv = process.argv;
500+
const originalExit = process.exit;
501+
502+
// process.exit를 무효화하여 프로그램이 종료되지 않도록 함
503+
process.exit = (code) => {
504+
if (code !== 0) {
505+
throw new Error(`Process exited with code ${code}`);
506+
}
507+
};
508+
509+
// --lang 옵션을 제외하고 재구성
510+
const filteredArgs = originalArgv.slice(2).filter(arg => !arg.startsWith('--lang='));
511+
process.argv = ['node', 'src/excel-cli.js', 'export', '--query', selectedFile.path, ...filteredArgs];
512+
513+
try {
514+
await excelCli.main();
515+
} finally {
516+
process.argv = originalArgv;
517+
process.exit = originalExit;
518+
}
519+
} else {
520+
// Node.js 환경: CLI 실행
521+
execSync(`node src/excel-cli.js export --query "${selectedFile.path}"`, {
522+
cwd: APP_ROOT,
523+
stdio: 'inherit',
524+
encoding: 'utf8'
525+
});
526+
}
446527

447528
const endTime = new Date();
448529

queries/test-sheet-name-validation.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,42 @@
1111
</sheet>
1212

1313
<!-- 허용되지 않는 문자 포함: 백슬래시 -->
14-
<sheet name="잘못된\시트명" use="true">
14+
<sheet name="잘못된\시트명1" use="true">
1515
<![CDATA[
1616
SELECT '백슬래시 포함' as 상태
1717
]]>
1818
</sheet>
1919

2020
<!-- 허용되지 않는 문자 포함: 슬래시 -->
21-
<sheet name="잘못된/시트명" use="true">
21+
<sheet name="잘못된/시트명2" use="true">
2222
<![CDATA[
2323
SELECT '슬래시 포함' as 상태
2424
]]>
2525
</sheet>
2626

2727
<!-- 허용되지 않는 문자 포함: 콜론 -->
28-
<sheet name="잘못된:시트명" use="true">
28+
<sheet name="잘못된:시트명3" use="true">
2929
<![CDATA[
3030
SELECT '콜론 포함' as 상태
3131
]]>
3232
</sheet>
3333

3434
<!-- 허용되지 않는 문자 포함: 별표 -->
35-
<sheet name="잘못된*시트명" use="true">
35+
<sheet name="잘못된*시트명4" use="true">
3636
<![CDATA[
3737
SELECT '별표 포함' as 상태
3838
]]>
3939
</sheet>
4040

4141
<!-- 허용되지 않는 문자 포함: 물음표 -->
42-
<sheet name="잘못된?시트명" use="true">
42+
<sheet name="잘못된?시트명5" use="true">
4343
<![CDATA[
4444
SELECT '물음표 포함' as 상태
4545
]]>
4646
</sheet>
4747

4848
<!-- 허용되지 않는 문자 포함: 대괄호 -->
49-
<sheet name="잘못된[시트명]" use="true">
49+
<sheet name="잘못된[시트명]6" use="true">
5050
<![CDATA[
5151
SELECT '대괄호 포함' as 상태
5252
]]>

0 commit comments

Comments
 (0)