@clazic/urban 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clazic/urban",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "도시계획연구 보고서 자동 수집·지식베이스 데몬",
5
5
  "type": "module",
6
6
  "engines": {
@@ -70,14 +70,25 @@ WantedBy=default.target
70
70
  /**
71
71
  * 순수 함수: Windows PowerShell 커맨드 생성
72
72
  */
73
- export function buildPowerShellCmd({ nodePath, daemonJs }) {
74
- // PowerShell 단따옴표 이스케이프: ' → ''
73
+ export function buildPowerShellCmd({ nodePath, daemonJs, urbanHome }) {
75
74
  const psEscape = (s) => s.replace(/'/g, "''");
76
- const escapedNodePath = psEscape(nodePath);
77
- const escapedDaemonJs = psEscape(daemonJs);
75
+
76
+ // VBScript 파일: URBAN_HOME에 저장
77
+ // wscript.exe(GUI 앱)로 실행하면 콘솔 창이 열리지 않음
78
+ const vbsPath = join(urbanHome, 'urban-launcher.vbs');
79
+ const escapedVbsPath = psEscape(vbsPath);
80
+ // VBScript 문자열 내 쌍따옴표 이스케이프 ("" = 리터럴 ")
81
+ const vbsNodePath = nodePath.replace(/"/g, '""');
82
+ const vbsDaemonJs = daemonJs.replace(/"/g, '""');
78
83
 
79
84
  return `
80
- $action = New-ScheduledTaskAction -Execute '${escapedNodePath}' -Argument '"${escapedDaemonJs}"'
85
+ $vbsPath = '${escapedVbsPath}'
86
+ $vbsContent = @'
87
+ Set oWsh = CreateObject("WScript.Shell")
88
+ oWsh.Run Chr(34) & "${vbsNodePath}" & Chr(34) & " " & Chr(34) & "${vbsDaemonJs}" & Chr(34), 0, True
89
+ '@
90
+ Set-Content -Path $vbsPath -Value $vbsContent -Encoding ASCII -Force
91
+ $action = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('"' + $vbsPath + '"')
81
92
  $trigger = New-ScheduledTaskTrigger -AtLogOn
82
93
  $settings = New-ScheduledTaskSettingsSet \`
83
94
  -ExecutionTimeLimit 0 \`
@@ -128,7 +139,7 @@ export async function installDaemon() {
128
139
  return { ok: true, message: `macOS 데몬 등록 완료: ${plistPath}` };
129
140
  } else if (isWindows) {
130
141
  // Windows: Task Scheduler (PowerShell)
131
- const ps = buildPowerShellCmd({ nodePath, daemonJs });
142
+ const ps = buildPowerShellCmd({ nodePath, daemonJs, urbanHome: URBAN_HOME });
132
143
  try {
133
144
  // -EncodedCommand: Base64(UTF-16LE) — 따옴표/특수문자 인젝션 방지
134
145
  const encoded = Buffer.from(ps, 'utf16le').toString('base64');
@@ -195,6 +206,9 @@ export async function uninstallDaemon() {
195
206
  } catch (err) {
196
207
  // 작업이 없거나 권한 부족 → 무시
197
208
  }
209
+ // VBScript 런처 파일 정리
210
+ const vbsPath = join(URBAN_HOME, 'urban-launcher.vbs');
211
+ if (existsSync(vbsPath)) rmSync(vbsPath);
198
212
  return { ok: true, message: `Windows 데몬 제거 완료` };
199
213
  } else if (isLinux) {
200
214
  try {