@joripspace/cli 0.5.6 → 0.5.8

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.
@@ -2,6 +2,7 @@ const crypto = require('node:crypto');
2
2
  const fs = require('node:fs');
3
3
  const path = require('node:path');
4
4
  const { unzipSync, zipSync } = require('fflate');
5
+ const ignore = require('ignore');
5
6
  const {
6
7
  assertNonOverlappingFilePlan,
7
8
  backupAndRemoveProjectPaths,
@@ -139,7 +140,12 @@ async function restoreCheckpoint(options) {
139
140
  'restore_safety'
140
141
  );
141
142
  const backupRoot = createExternalBackupRoot(options.workspaceDir, 'checkpoint-restore', options.dataDir);
142
- backupAndRemoveProjectPaths(options.workspaceDir, [...conflictPaths, ...deletions], backupRoot);
143
+ backupAndRemoveProjectPaths(
144
+ options.workspaceDir,
145
+ [...conflictPaths, ...deletions],
146
+ backupRoot,
147
+ (relative) => hardExcluded(relative) || isLocalRestoreMarker(relative)
148
+ );
143
149
  for (const [relative, bytes] of writable) {
144
150
  const location = resolveProjectFileTarget(options.workspaceDir, relative, 'unsafe checkpoint path');
145
151
  if (location.blockers.length) {
@@ -167,22 +173,29 @@ async function restoreCheckpoint(options) {
167
173
  }
168
174
 
169
175
  function projectFiles(root) {
170
- const rules = ignoreRules(root);
171
176
  const files = [];
172
- function walk(directory) {
177
+ function walk(directory, inherited = []) {
178
+ const names = directory === root ? ['.gitignore', '.ignore', '.joripspaceignore'] : ['.gitignore'];
179
+ const rules = [...inherited, { directory, matcher: ignoreRules(directory, names) }];
173
180
  for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
174
181
  const full = path.join(directory, entry.name);
175
182
  let relative = toPosix(path.relative(root, full));
176
183
  if (hardExcluded(relative)) continue;
177
- const excluded = ignored(relative, rules);
178
- if (excluded && (!entry.isDirectory() || !negatedRuleCanInclude(relative, rules))) continue;
184
+ let excluded = false;
185
+ for (const rule of rules) {
186
+ const candidate = toPosix(path.relative(rule.directory, full)) + (entry.isDirectory() ? '/' : '');
187
+ const result = rule.matcher.test(candidate);
188
+ if (result.ignored || result.unignored) excluded = result.ignored;
189
+ }
190
+ // Git cannot reinclude a child of an excluded directory without reopening the parent.
191
+ if (excluded) continue;
179
192
  relative = safeProjectRelativePath(relative, 'unsafe checkpoint path');
180
193
  const stat = fs.lstatSync(full);
181
194
  if (stat.isSymbolicLink())
182
195
  throw new Error(`symbolic links cannot be included in checkpoints: ${relative}`);
183
196
  if (entry.isDirectory()) {
184
- if (!excluded || negatedRuleCanInclude(relative, rules)) walk(full);
185
- } else if (entry.isFile() && !excluded) {
197
+ walk(full, rules);
198
+ } else if (entry.isFile()) {
186
199
  files.push([relative, new Uint8Array(fs.readFileSync(full))]);
187
200
  }
188
201
  }
@@ -199,9 +212,9 @@ function hardExcluded(relative) {
199
212
  HARD_FILES.has(base) ||
200
213
  parts.some((part) => HARD_DIRS.has(part)) ||
201
214
  parts.some((part) => AGENT_CONTROL_DIRS.has(part)) ||
202
- AGENT_CONTROL_FILES.has(base) ||
215
+ parts.some((part) => AGENT_CONTROL_FILES.has(part)) ||
203
216
  parts.includes('.joripspace') ||
204
- base === '.env.joripspace' ||
217
+ parts.includes('.env.joripspace') ||
205
218
  /\.(log|tmp|temp)$/i.test(base)
206
219
  );
207
220
  }
@@ -283,52 +296,30 @@ function upsertDeployManifest(files, workspaceDir, entrypoint) {
283
296
  else files.push([TRANSIENT_DEPLOY_MANIFEST, bytes]);
284
297
  }
285
298
 
286
- function ignoreRules(root) {
287
- const rules = [];
288
- for (const name of ['.gitignore', '.ignore', '.joripspaceignore']) {
299
+ function ignoreRules(directory, names) {
300
+ const matcher = ignore({ ignorecase: false });
301
+ for (const name of names) {
302
+ const target = path.join(directory, name);
303
+ let stat;
289
304
  try {
290
- for (const line of fs.readFileSync(path.join(root, name), 'utf8').split(/\r?\n/)) {
291
- const value = line.trim();
292
- if (value && !value.startsWith('#')) rules.push(value);
293
- }
294
- } catch {}
295
- }
296
- return rules;
297
- }
298
-
299
- function globRegex(pattern) {
300
- const clean = pattern.replace(/^!/, '').replace(/^\//, '').replace(/\/$/, '/**');
301
- const escaped = clean
302
- .replace(/[.+^$(){}|[\]\\]/g, '\\$&')
303
- .replace(/\*\*/g, '§§')
304
- .replace(/\*/g, '[^/]*')
305
- .replace(/§§/g, '.*')
306
- .replace(/\?/g, '.');
307
- return new RegExp(`^(?:${escaped})(?:/.*)?$`);
308
- }
309
-
310
- function ignored(relative, rules) {
311
- if (hardExcluded(relative)) return true;
312
- const normalized = toPosix(relative);
313
- let result = false;
314
- for (const rule of rules) {
315
- if (globRegex(rule).test(normalized)) result = !rule.startsWith('!');
305
+ stat = fs.lstatSync(target);
306
+ } catch (error) {
307
+ if (error?.code === 'ENOENT') continue;
308
+ throw error;
309
+ }
310
+ if (!stat.isFile() || stat.isSymbolicLink())
311
+ throw new Error(`ignore rules must be a regular file: ${name}`);
312
+ matcher.add(fs.readFileSync(target, 'utf8'));
316
313
  }
317
- return result;
318
- }
319
-
320
- function negatedRuleCanInclude(directory, rules) {
321
- const prefix = `${toPosix(directory).replace(/\/$/, '')}/`;
322
- return rules.some((rule) => {
323
- if (!rule.startsWith('!')) return false;
324
- const target = rule.slice(1).replace(/^\//, '').replace(/\*.*$/, '');
325
- return target.startsWith(prefix) || prefix.startsWith(`${target.replace(/\/$/, '')}/`);
326
- });
314
+ return matcher;
327
315
  }
328
316
 
329
317
  function safeRestorePath(name) {
330
318
  const normalized = safeProjectRelativePath(name, 'unsafe checkpoint path');
331
- if (hardExcluded(normalized) && !isCheckpointMetadataFile(normalized)) {
319
+ if (
320
+ (hardExcluded(normalized) && !isCheckpointMetadataFile(normalized)) ||
321
+ [...LOCAL_RESTORE_MARKERS].some((marker) => portablePathKey(normalized).startsWith(`${marker}/`))
322
+ ) {
332
323
  throw new Error(`protected file cannot be restored: ${normalized}`);
333
324
  }
334
325
  return normalized;
@@ -1,3 +1,4 @@
1
+ const { message } = require('./locale');
1
2
  const fs = require('node:fs');
2
3
  const os = require('node:os');
3
4
  const path = require('node:path');
@@ -27,10 +28,11 @@ function createCheckpointCommands(deps) {
27
28
  deps.output(flags, body, (value) => {
28
29
  for (const item of value.checkpoints || []) {
29
30
  console.log(
30
- `#${item.sequence}\t${item.checkpoint_id}\t${item.label || '(이름 없음)'}\t${item.status}\t${item.deployable ? '배포 가능' : '백업 전용'}`
31
+ `#${item.sequence}\t${item.checkpoint_id}\t${item.label || message('(unnamed)', '(이름 없음)')}\t${item.status}\t${item.deployable ? message('deployable', '배포 가능') : message('backup only', '백업 전용')}`
31
32
  );
32
33
  }
33
- if (value.next_cursor) console.log(`다음 cursor: ${value.next_cursor}`);
34
+ if (value.next_cursor)
35
+ console.log(message(`Next cursor: ${value.next_cursor}`, `다음 cursor: ${value.next_cursor}`));
34
36
  });
35
37
  return;
36
38
  }
@@ -39,10 +41,12 @@ function createCheckpointCommands(deps) {
39
41
  if (subcommand === 'get') {
40
42
  const body = await deps.apiRequest(flags, itemPath, { method: 'GET', ...deps.projectAuth(flags) });
41
43
  deps.output(flags, body, (value) => {
42
- console.log(`#${value.sequence} ${value.label || '(이름 없음)'}`);
43
- console.log(`상태: ${value.status}`);
44
- console.log(`배포: ${value.deployable ? '가능' : '백업 전용'}`);
45
- console.log(`파일: ${value.file_count || 0}개`);
44
+ console.log(`#${value.sequence} ${value.label || message('(unnamed)', '(이름 없음)')}`);
45
+ console.log(message(`Status: ${value.status}`, `상태: ${value.status}`));
46
+ console.log(
47
+ `${message('Deployment', '배포')}: ${value.deployable ? message('available', '가능') : message('backup only', '백업 전용')}`
48
+ );
49
+ console.log(message(`Files: ${value.file_count || 0}`, `파일: ${value.file_count || 0}개`));
46
50
  });
47
51
  return;
48
52
  }
@@ -58,13 +62,17 @@ function createCheckpointCommands(deps) {
58
62
  ...deps.projectAuth(flags),
59
63
  body: bodyInput,
60
64
  });
61
- deps.output(flags, body, (value) => console.log(`저장본 #${value.sequence} 정보를 변경했습니다.`));
65
+ deps.output(flags, body, (value) =>
66
+ console.log(
67
+ message(`Checkpoint #${value.sequence} updated.`, `저장본 #${value.sequence} 정보를 변경했습니다.`)
68
+ )
69
+ );
62
70
  return;
63
71
  }
64
72
  if (subcommand === 'delete') {
65
73
  if (!deps.booleanFlag(flags, 'yes')) throw new Error('checkpoint delete requires --yes');
66
74
  const body = await deps.apiRequest(flags, itemPath, { method: 'DELETE', ...deps.projectAuth(flags) });
67
- deps.output(flags, body, () => console.log('저장본을 삭제했습니다.'));
75
+ deps.output(flags, body, () => console.log(message('Checkpoint deleted.', '저장본을 삭제했습니다.')));
68
76
  return;
69
77
  }
70
78
  if (subcommand === 'deploy') {
@@ -74,7 +82,12 @@ function createCheckpointCommands(deps) {
74
82
  body: {},
75
83
  });
76
84
  deps.output(flags, body, (value) => {
77
- console.log(`저장본을 배포했습니다: ${value.url || project}`);
85
+ console.log(
86
+ message(
87
+ `Checkpoint deployed: ${value.url || project}`,
88
+ `저장본을 배포했습니다: ${value.url || project}`
89
+ )
90
+ );
78
91
  console.log(`Deployment: ${value.deployment_id}`);
79
92
  printCheckpointWarnings(value.warnings);
80
93
  });
@@ -97,21 +110,43 @@ function createCheckpointCommands(deps) {
97
110
  });
98
111
  deps.output(flags, value, (result) => {
99
112
  if (result.status === 'saved') {
100
- console.log(`저장본 #${result.checkpoint.sequence}을 만들었습니다. 파일 ${result.file_count}개`);
113
+ console.log(
114
+ message(
115
+ `Checkpoint #${result.checkpoint.sequence} created. Files: ${result.file_count}`,
116
+ `저장본 #${result.checkpoint.sequence}을 만들었습니다. 파일 ${result.file_count}개`
117
+ )
118
+ );
101
119
  printCheckpointWarnings(result.checkpoint.warnings);
102
120
  if (result.deployment) {
103
121
  console.log(
104
- `같은 저장본으로 배포했습니다: ${result.deployment.url || result.checkpoint.checkpoint_id}`
122
+ message(
123
+ `Deployed the same checkpoint: ${result.deployment.url || result.checkpoint.checkpoint_id}`,
124
+ `같은 저장본으로 배포했습니다: ${result.deployment.url || result.checkpoint.checkpoint_id}`
125
+ )
105
126
  );
106
127
  }
107
128
  return;
108
129
  }
109
130
  console.log(
110
- `추가 ${result.additions.length}개, 덮어쓰기 ${result.overwrites.length}개, 삭제 ${result.deletions.length}개`
131
+ message(
132
+ `Additions: ${result.additions.length}, overwrites: ${result.overwrites.length}, deletions: ${result.deletions.length}`,
133
+ `추가 ${result.additions.length}개, 덮어쓰기 ${result.overwrites.length}개, 삭제 ${result.deletions.length}개`
134
+ )
111
135
  );
112
136
  if (result.status === 'preview') {
113
- console.log('미리보기만 했습니다. 승인 후 --apply를 붙여 다시 실행하세요.');
114
- } else console.log(`로컬 파일을 복원했습니다. 백업: ${result.backup_root}`);
137
+ console.log(
138
+ message(
139
+ 'Preview only. After approval, run again with --apply.',
140
+ '미리보기만 했습니다. 승인 후 --apply를 붙여 다시 실행하세요.'
141
+ )
142
+ );
143
+ } else
144
+ console.log(
145
+ message(
146
+ `Local files restored. Backup: ${result.backup_root}`,
147
+ `로컬 파일을 복원했습니다. 백업: ${result.backup_root}`
148
+ )
149
+ );
115
150
  });
116
151
  }
117
152
 
@@ -205,7 +240,8 @@ function createCheckpointCommands(deps) {
205
240
  }
206
241
 
207
242
  function printCheckpointWarnings(warnings) {
208
- for (const warning of warnings || []) console.warn(`경고: ${warning.message}`);
243
+ for (const warning of warnings || [])
244
+ console.warn(message(`Warning: ${warning.message}`, `경고: ${warning.message}`));
209
245
  }
210
246
 
211
247
  module.exports = { createCheckpointCommands };
@@ -0,0 +1,148 @@
1
+ const { message } = require('./locale');
2
+ const { createHash } = require('node:crypto');
3
+
4
+ const SERVICE = 'com.joripspace.cli.v1';
5
+
6
+ function storeError(code = 'credential_store_unavailable') {
7
+ const error = new Error(
8
+ code === 'credential_store_invalid'
9
+ ? message(
10
+ 'The JoripSpace connection in the OS credential store is invalid. Reconnect with login --code.',
11
+ 'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login --code로 다시 연결하세요.'
12
+ )
13
+ : message(
14
+ 'The OS credential store is unavailable. Check Windows Credential Manager, macOS Keychain, or Linux Secret Service. No plaintext fallback is used. For automation, provide JORIPSPACE_API_TOKEN and its API URL through environment variables.',
15
+ 'OS 보안 저장소를 사용할 수 없습니다. Windows 자격 증명 관리자, macOS Keychain 또는 Linux Secret Service를 확인하세요. 평문 파일에는 저장하지 않습니다. 자동화에서는 JORIPSPACE_API_TOKEN과 해당 API URL을 환경 변수로 제공할 수 있습니다.'
16
+ )
17
+ );
18
+ error.code = code;
19
+ return error;
20
+ }
21
+
22
+ function normalizeCredentialApiUrl(value) {
23
+ let url;
24
+ try {
25
+ url = new URL(value);
26
+ } catch {
27
+ throw storeError('credential_store_invalid');
28
+ }
29
+ const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
30
+ if (
31
+ (url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) ||
32
+ url.username ||
33
+ url.password ||
34
+ url.search ||
35
+ url.hash
36
+ ) {
37
+ throw storeError('credential_store_invalid');
38
+ }
39
+ return url.href.replace(/\/+$/, '');
40
+ }
41
+
42
+ function digest(value) {
43
+ return createHash('sha256').update(value).digest('hex');
44
+ }
45
+
46
+ // Injection is confined to this module's constructor for unit tests. The CLI always
47
+ // uses the native binding; there is no configurable plaintext backend or shell helper.
48
+ function createCredentialStore(loadBinding = () => require('@napi-rs/keyring'), platform = process.platform) {
49
+ function entry(apiBaseUrl, accountId) {
50
+ try {
51
+ if (!['win32', 'darwin', 'linux'].includes(platform)) throw storeError();
52
+ const { Entry } = loadBinding();
53
+ const key = `${digest(apiBaseUrl)}:${accountId ? digest(accountId) : 'default'}`;
54
+ // The library otherwise falls back to a nonpersistent kernel keyring on Linux.
55
+ return new Entry(SERVICE, key, { linux: { store: 'secret-service' } });
56
+ } catch {
57
+ throw storeError();
58
+ }
59
+ }
60
+
61
+ function read(entry) {
62
+ let value;
63
+ try {
64
+ value = entry.getPassword();
65
+ } catch {
66
+ throw storeError();
67
+ }
68
+ if (value === null || value === undefined) return null;
69
+ try {
70
+ const record = JSON.parse(value);
71
+ if (!record || record.version !== 1 || typeof record.account_id !== 'string' || !record.account_id) {
72
+ throw storeError();
73
+ }
74
+ return record;
75
+ } catch {
76
+ throw storeError('credential_store_invalid');
77
+ }
78
+ }
79
+
80
+ function load(apiUrl, requestedAccountId = '') {
81
+ const apiBaseUrl = normalizeCredentialApiUrl(apiUrl);
82
+ const accountId = requestedAccountId || read(entry(apiBaseUrl))?.account_id;
83
+ if (!accountId) return null;
84
+ const record = read(entry(apiBaseUrl, accountId));
85
+ if (!record) return null;
86
+ if (
87
+ record.api_base_url !== apiBaseUrl ||
88
+ record.account_id !== accountId ||
89
+ typeof record.api_token !== 'string' ||
90
+ !record.api_token.trim() ||
91
+ /[\r\n]/.test(record.api_token)
92
+ ) {
93
+ throw storeError('credential_store_invalid');
94
+ }
95
+ return { apiBaseUrl, apiToken: record.api_token, accountId, source: 'os-credential-store' };
96
+ }
97
+
98
+ function save({ apiBaseUrl: apiUrl, apiToken, accountId }) {
99
+ const apiBaseUrl = normalizeCredentialApiUrl(apiUrl);
100
+ if (
101
+ typeof accountId !== 'string' ||
102
+ !accountId ||
103
+ typeof apiToken !== 'string' ||
104
+ !apiToken.trim() ||
105
+ /[\r\n]/.test(apiToken)
106
+ ) {
107
+ throw storeError('credential_store_invalid');
108
+ }
109
+ const account = entry(apiBaseUrl, accountId);
110
+ const record = { version: 1, api_base_url: apiBaseUrl, account_id: accountId, api_token: apiToken };
111
+ try {
112
+ account.setPassword(JSON.stringify(record));
113
+ if (account.getPassword() !== JSON.stringify(record)) throw storeError();
114
+ const selected = entry(apiBaseUrl);
115
+ const pointer = JSON.stringify({ version: 1, account_id: accountId });
116
+ selected.setPassword(pointer);
117
+ if (selected.getPassword() !== pointer) throw storeError();
118
+ } catch {
119
+ // Native errors can contain secret values. Never propagate them to CLI output.
120
+ throw storeError();
121
+ }
122
+ return { apiBaseUrl, apiToken, accountId, source: 'os-credential-store' };
123
+ }
124
+
125
+ function remove(apiUrl, requestedAccountId = '') {
126
+ const apiBaseUrl = normalizeCredentialApiUrl(apiUrl);
127
+ const selected = entry(apiBaseUrl);
128
+ const selectedAccountId = read(selected)?.account_id;
129
+ const accountId = requestedAccountId || selectedAccountId;
130
+ if (!accountId) return false;
131
+ const account = entry(apiBaseUrl, accountId);
132
+ try {
133
+ account.deleteCredential();
134
+ if (account.getPassword() !== null) throw storeError();
135
+ if (selectedAccountId === accountId) {
136
+ selected.deleteCredential();
137
+ if (selected.getPassword() !== null) throw storeError();
138
+ }
139
+ } catch {
140
+ throw storeError();
141
+ }
142
+ return true;
143
+ }
144
+
145
+ return { load, save, remove };
146
+ }
147
+
148
+ module.exports = { createCredentialStore, normalizeCredentialApiUrl };
@@ -230,7 +230,13 @@ function isProtectedSourcePath(value) {
230
230
  const resolved = path.resolve(value);
231
231
  const baseName = path.basename(resolved);
232
232
  const parts = resolved.replace(/\\/g, '/').toLowerCase().split('/');
233
- return isProtectedProjectPath(baseName) || parts.some((part) => PROTECTED_SOURCE_DIRS.has(part));
233
+ return (
234
+ isProtectedProjectPath(baseName) ||
235
+ parts.some(
236
+ (part) =>
237
+ PROTECTED_SOURCE_DIRS.has(part) || part === '.env.joripspace' || PROTECTED_FILE_NAMES.has(part)
238
+ )
239
+ );
234
240
  }
235
241
 
236
242
  function isContainedPath(root, target) {
@@ -250,8 +256,7 @@ function isProtectedProjectPath(value) {
250
256
  const baseName = parts.at(-1) || '';
251
257
  return (
252
258
  parts.some((part) => IGNORED_DIRS.has(part)) ||
253
- baseName === '.env.joripspace' ||
254
- PROTECTED_FILE_NAMES.has(baseName) ||
259
+ parts.some((part) => part === '.env.joripspace' || PROTECTED_FILE_NAMES.has(part)) ||
255
260
  baseName.endsWith('.log')
256
261
  );
257
262
  }
@@ -1,14 +1,14 @@
1
- 'use strict';
2
-
3
- function formatDeploymentFailure(message, details) {
4
- if (!details || typeof details !== 'object' || !details.deployment_id) return message;
5
- const lines = [message, `Deployment: ${details.deployment_id}`];
6
- if (details.error_stage) lines.push(`Stage: ${details.error_stage}`);
7
- if (details.error_code) lines.push(`Error code: ${details.error_code}`);
8
- if (details.error_details && details.error_details !== message) {
9
- lines.push(`Details: ${details.error_details}`);
10
- }
11
- return lines.join('\n');
12
- }
13
-
14
- module.exports = { formatDeploymentFailure };
1
+ 'use strict';
2
+
3
+ function formatDeploymentFailure(message, details) {
4
+ if (!details || typeof details !== 'object' || !details.deployment_id) return message;
5
+ const lines = [message, `Deployment: ${details.deployment_id}`];
6
+ if (details.error_stage) lines.push(`Stage: ${details.error_stage}`);
7
+ if (details.error_code) lines.push(`Error code: ${details.error_code}`);
8
+ if (details.error_details && details.error_details !== message) {
9
+ lines.push(`Details: ${details.error_details}`);
10
+ }
11
+ return lines.join('\n');
12
+ }
13
+
14
+ module.exports = { formatDeploymentFailure };
@@ -1,3 +1,4 @@
1
+ const { message } = require('./locale');
1
2
  const fs = require('node:fs');
2
3
  const path = require('node:path');
3
4
  const { spawnSync } = require('node:child_process');
@@ -18,17 +19,39 @@ function createGithubCommands({ apiRequest, output, projectAuth, projectWorkspac
18
19
  });
19
20
  const deployment = details?.deployment;
20
21
  if (!deployment || deployment.mode !== 'github_actions') {
21
- throw commandError('github_connection_required', '이 프로젝트에는 GitHub 저장소가 연결되어 있지 않습니다.');
22
+ throw commandError(
23
+ 'github_connection_required',
24
+ message(
25
+ 'No GitHub repository is connected to this project.',
26
+ '이 프로젝트에는 GitHub 저장소가 연결되어 있지 않습니다.'
27
+ )
28
+ );
22
29
  }
23
30
  const repository = String(deployment.repository || '').trim();
24
31
  const branch = String(deployment.branch || '').trim();
25
32
  const connectionId = String(deployment.connection_id || '').trim();
26
33
  const workflowPath = String(deployment.workflow_path || '').trim();
27
34
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository)) {
28
- throw commandError('github_repository_invalid', '연결된 GitHub 저장소 정보가 올바르지 않습니다.');
35
+ throw commandError(
36
+ 'github_repository_invalid',
37
+ message(
38
+ 'The connected GitHub repository information is invalid.',
39
+ '연결된 GitHub 저장소 정보가 올바르지 않습니다.'
40
+ )
41
+ );
29
42
  }
30
- if (!validGitBranch(branch) || !connectionId || !/^\.github\/workflows\/joripspace-[a-z0-9_-]+\.ya?ml$/u.test(workflowPath)) {
31
- throw commandError('github_connection_invalid', '연결된 GitHub 배포 설정이 올바르지 않습니다.');
43
+ if (
44
+ !validGitBranch(branch) ||
45
+ !connectionId ||
46
+ !/^\.github\/workflows\/joripspace-[a-z0-9_-]+\.ya?ml$/u.test(workflowPath)
47
+ ) {
48
+ throw commandError(
49
+ 'github_connection_invalid',
50
+ message(
51
+ 'The connected GitHub deployment configuration is invalid.',
52
+ '연결된 GitHub 배포 설정이 올바르지 않습니다.'
53
+ )
54
+ );
32
55
  }
33
56
  assertMatchingGitWorkspace(workspace, repository, branch);
34
57
 
@@ -43,7 +66,13 @@ function createGithubCommands({ apiRequest, output, projectAuth, projectWorkspac
43
66
  });
44
67
  const workflowTarget = resolveProjectFileTarget(workspace, workflowPath);
45
68
  if (workflowTarget.blockers.length) {
46
- throw commandError('github_workflow_path_invalid', `workflow 경로가 파일에 막혀 있습니다: ${workflowPath}`);
69
+ throw commandError(
70
+ 'github_workflow_path_invalid',
71
+ message(
72
+ `The workflow path is blocked by a file: ${workflowPath}`,
73
+ `workflow 경로가 파일에 막혀 있습니다: ${workflowPath}`
74
+ )
75
+ );
47
76
  }
48
77
  const target = workflowTarget.target;
49
78
  if (fs.existsSync(target)) {
@@ -52,7 +81,10 @@ function createGithubCommands({ apiRequest, output, projectAuth, projectWorkspac
52
81
  if (!existing.startsWith('# joripspace-workflow-version: ') || !existing.includes(connectionMarker)) {
53
82
  throw commandError(
54
83
  'github_workflow_conflict',
55
- `기존 workflow를 덮어쓰지 않았습니다: ${workflowPath}`
84
+ message(
85
+ `The existing workflow was not overwritten: ${workflowPath}`,
86
+ `기존 workflow를 덮어쓰지 않았습니다: ${workflowPath}`
87
+ )
56
88
  );
57
89
  }
58
90
  }
@@ -116,7 +148,10 @@ function inferWorkflowConfig(workspace, flags, stringFlag) {
116
148
  if (!entrypoint) {
117
149
  throw commandError(
118
150
  'github_entrypoint_not_detected',
119
- 'Worker 시작 파일을 찾지 못했습니다. 소스를 작성하거나 --entrypoint를 지정한 뒤 다시 실행해 주세요.'
151
+ message(
152
+ 'No Worker entrypoint was found. Create the source or specify --entrypoint, then try again.',
153
+ 'Worker 시작 파일을 찾지 못했습니다. 소스를 작성하거나 --entrypoint를 지정한 뒤 다시 실행해 주세요.'
154
+ )
120
155
  );
121
156
  }
122
157
  const scripts = packageJson.scripts && typeof packageJson.scripts === 'object' ? packageJson.scripts : {};
@@ -141,15 +176,33 @@ function inferWorkflowConfig(workspace, flags, stringFlag) {
141
176
  function assertMatchingGitWorkspace(workspace, repository, branch) {
142
177
  const inside = git(workspace, ['rev-parse', '--is-inside-work-tree']);
143
178
  if (inside.status !== 0 || inside.stdout.trim() !== 'true') {
144
- throw commandError('github_workspace_required', '먼저 joripspace start를 실행해 연결된 GitHub 작업 폴더를 준비해 주세요.');
179
+ throw commandError(
180
+ 'github_workspace_required',
181
+ message(
182
+ 'Run joripspace start first to prepare the connected GitHub workspace.',
183
+ '먼저 joripspace start를 실행해 연결된 GitHub 작업 폴더를 준비해 주세요.'
184
+ )
185
+ );
145
186
  }
146
187
  const remote = git(workspace, ['remote', 'get-url', 'origin']);
147
188
  if (remote.status !== 0 || githubRepository(remote.stdout.trim()) !== repository.toLowerCase()) {
148
- throw commandError('github_repository_mismatch', '현재 작업 폴더의 origin이 연결된 GitHub 저장소와 다릅니다.');
189
+ throw commandError(
190
+ 'github_repository_mismatch',
191
+ message(
192
+ 'The workspace origin does not match the connected GitHub repository.',
193
+ '현재 작업 폴더의 origin이 연결된 GitHub 저장소와 다릅니다.'
194
+ )
195
+ );
149
196
  }
150
197
  const currentBranch = git(workspace, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
151
198
  if (currentBranch.status !== 0 || currentBranch.stdout.trim() !== branch) {
152
- throw commandError('github_branch_mismatch', `현재 작업 브랜치가 연결된 ${branch} 브랜치와 다릅니다.`);
199
+ throw commandError(
200
+ 'github_branch_mismatch',
201
+ message(
202
+ `The current branch does not match the connected branch: ${branch}.`,
203
+ `현재 작업 브랜치가 연결된 ${branch} 브랜치와 다릅니다.`
204
+ )
205
+ );
153
206
  }
154
207
  }
155
208
 
@@ -158,13 +211,23 @@ function git(workspace, args) {
158
211
  }
159
212
 
160
213
  function githubRepository(remote) {
161
- const value = String(remote || '').trim().replace(/\.git$/iu, '');
162
- const match = /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+\/[^/]+)$/iu.exec(value);
214
+ const value = String(remote || '')
215
+ .trim()
216
+ .replace(/\.git$/iu, '');
217
+ const match =
218
+ /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+\/[^/]+)$/iu.exec(value);
163
219
  return match ? match[1].toLowerCase() : '';
164
220
  }
165
221
 
166
222
  function validGitBranch(value) {
167
- return Boolean(value) && value !== '@' && !value.startsWith('-') && !/[\x00-\x20\x7f~^:?*\\]/u.test(value) && !value.includes('..') && !value.includes('@{');
223
+ return (
224
+ Boolean(value) &&
225
+ value !== '@' &&
226
+ !value.startsWith('-') &&
227
+ !/[\x00-\x20\x7f~^:?*\\]/u.test(value) &&
228
+ !value.includes('..') &&
229
+ !value.includes('@{')
230
+ );
168
231
  }
169
232
 
170
233
  function readJson(filePath) {