viruagent-cli 0.4.1 → 0.5.0

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.
@@ -31,19 +31,19 @@ const normalizeCookies = (session) => {
31
31
  const readSessionCookies = (sessionPath) => {
32
32
  const resolvedPath = path.resolve(sessionPath);
33
33
  if (!fs.existsSync(resolvedPath)) {
34
- throw new Error(`세션 파일이 없습니다. ${resolvedPath} 로그인 정보를 먼저 저장하세요.`);
34
+ throw new Error(`Session file not found. Please save login credentials to ${resolvedPath} first.`);
35
35
  }
36
36
 
37
37
  let raw;
38
38
  try {
39
39
  raw = JSON.parse(fs.readFileSync(resolvedPath, 'utf-8'));
40
40
  } catch (error) {
41
- throw new Error(`세션 파일 파싱 실패: ${error.message}`);
41
+ throw new Error(`Failed to parse session file: ${error.message}`);
42
42
  }
43
43
 
44
44
  const cookies = normalizeCookies(raw);
45
45
  if (!cookies.length) {
46
- throw new Error('세션에 유효한 쿠키가 없습니다. 다시 로그인해 주세요.');
46
+ throw new Error('No valid cookies found in session. Please log in again.');
47
47
  }
48
48
 
49
49
  return cookies.join('; ');
@@ -70,7 +70,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
70
70
 
71
71
  const getBase = () => {
72
72
  if (!blogName) {
73
- throw new Error('블로그 이름이 초기화되지 않았습니다. initBlog() 먼저 호출하세요.');
73
+ throw new Error('Blog name not initialized. Call initBlog() first.');
74
74
  }
75
75
  return `https://${blogName}.tistory.com/manage`;
76
76
  };
@@ -131,7 +131,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
131
131
  } catch {
132
132
  detail = '';
133
133
  }
134
- throw new Error(`요청 실패: ${response.status} ${response.statusText}${detail}`);
134
+ throw new Error(`Request failed: ${response.status} ${response.statusText}${detail}`);
135
135
  }
136
136
  return response.json();
137
137
  } finally {
@@ -148,7 +148,7 @@ const createTistoryApiClient = ({ sessionPath }) => {
148
148
  ...options,
149
149
  });
150
150
  if (!response.ok) {
151
- throw new Error(`요청 실패: ${response.status} ${response.statusText}`);
151
+ throw new Error(`Request failed: ${response.status} ${response.statusText}`);
152
152
  }
153
153
  return response.text();
154
154
  } finally {
@@ -181,18 +181,18 @@ const createTistoryApiClient = ({ sessionPath }) => {
181
181
  redirect: 'follow',
182
182
  });
183
183
  if (!response.ok) {
184
- throw new Error(`블로그 정보 조회 실패: ${response.status}`);
184
+ throw new Error(`Failed to fetch blog info: ${response.status}`);
185
185
  }
186
186
 
187
187
  const contentType = response.headers.get('content-type') || '';
188
188
  if (!contentType.includes('application/json')) {
189
- throw new Error('세션이 만료되었습니다. /auth/login으로 다시 로그인하세요.');
189
+ throw new Error('Session expired. Please log in again via /auth/login.');
190
190
  }
191
191
 
192
192
  const json = await response.json();
193
193
  const defaultBlog = (json?.data || []).find((blog) => blog?.defaultBlog) || (json?.data || [])[0];
194
194
  if (!defaultBlog) {
195
- throw new Error('블로그를 찾을 수 없습니다.');
195
+ throw new Error('Blog not found.');
196
196
  }
197
197
 
198
198
  blogName = defaultBlog.name;
@@ -255,14 +255,14 @@ const createTistoryApiClient = ({ sessionPath }) => {
255
255
 
256
256
  const match = html.match(/window\.Config\s*=\s*(\{[\s\S]*?\})\s*(?:\n|;)/);
257
257
  if (!match) {
258
- throw new Error('카테고리 파싱 실패');
258
+ throw new Error('Failed to parse categories');
259
259
  }
260
260
 
261
261
  const sandbox = {};
262
262
  vm.runInNewContext(`var result = ${match[1]};`, sandbox);
263
263
  const rootCategories = sandbox?.result?.blog?.categories;
264
264
  if (!Array.isArray(rootCategories)) {
265
- throw new Error('카테고리 파싱 실패');
265
+ throw new Error('Failed to parse categories');
266
266
  }
267
267
 
268
268
  return flattenCategories(rootCategories, {});
@@ -287,12 +287,12 @@ const createTistoryApiClient = ({ sessionPath }) => {
287
287
 
288
288
  if (!response.ok) {
289
289
  const text = await response.text().catch(() => '');
290
- throw new Error(`이미지 업로드 실패: ${response.status} ${text ? `: ${text.slice(0, 500)}` : ''}`);
290
+ throw new Error(`Image upload failed: ${response.status} ${text ? `: ${text.slice(0, 500)}` : ''}`);
291
291
  }
292
292
 
293
293
  const uploaded = await response.json();
294
294
  if (!uploaded?.url) {
295
- throw new Error('이미지 업로드 응답에 URL이 없습니다.');
295
+ throw new Error('Image upload response does not contain a URL.');
296
296
  }
297
297
  return uploaded;
298
298
  };