@joripspace/cli 0.4.1

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.
@@ -0,0 +1,401 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const {
4
+ assertNonOverlappingFilePlan,
5
+ backupAndRemoveProjectPaths,
6
+ createExternalBackupRoot,
7
+ resolveProjectFileTarget,
8
+ safeProjectRelativePath,
9
+ } = require('./project-paths');
10
+ const { ensureProjectEnvIgnored } = require('./project-env');
11
+
12
+ function createRemoteCommands(deps) {
13
+ async function knowledge(rest, flags) {
14
+ const subcommand = rest[0] || 'search';
15
+ if (subcommand !== 'search') throw new Error('knowledge command requires: search');
16
+ const query = deps.stringFlag(flags, 'query') || deps.stringFlag(flags, 'q') || rest.slice(1).join(' ');
17
+ if (!query.trim()) throw new Error('knowledge search requires --query');
18
+ const params = new URLSearchParams({ q: query });
19
+ const limit = deps.positiveIntegerFlag(flags, 'limit');
20
+ if (limit) params.set('limit', String(limit));
21
+ const body = await deps.apiRequest(flags, `/v1/knowledge/search?${params}`, { method: 'GET' });
22
+ deps.output(flags, body, (value) => {
23
+ for (const item of value.results || value.items || []) {
24
+ console.log(
25
+ `${item.title || item.name || item.id || 'result'}\t${item.summary || item.description || ''}`
26
+ );
27
+ }
28
+ });
29
+ }
30
+
31
+ async function deployment(rest, flags) {
32
+ if (rest[0] === 'get') {
33
+ const project = deps.requireProjectId(flags);
34
+ const id = deps.stringFlag(flags, 'deployment') || deps.stringFlag(flags, 'deployment-id');
35
+ if (!id) throw new Error('deployment get requires --deployment');
36
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/deployments/${encodeURIComponent(id)}`, { method: 'GET', ...deps.projectAuth(flags) });
37
+ deps.output(flags, body, (value) => console.log(JSON.stringify(value, null, 2)));
38
+ return;
39
+ }
40
+ if (rest[0] !== 'pull' && rest[0] !== 'source') throw new Error('deployment command requires: pull');
41
+ await pullDeploymentSource(flags);
42
+ }
43
+
44
+ async function pullDeploymentSource(flags, options = {}) {
45
+ const project = deps.requireProjectId(flags);
46
+ const deploymentId =
47
+ deps.stringFlag(flags, 'deployment') ||
48
+ deps.stringFlag(flags, 'deployment-id') ||
49
+ deps.stringFlag(flags, 'deployment_id') ||
50
+ 'latest';
51
+ const body = await deps.apiRequest(
52
+ flags,
53
+ `/v1/projects/${encodeURIComponent(project)}/deployments/${encodeURIComponent(deploymentId)}/source`,
54
+ { method: 'GET', ...deps.projectAuth(flags) }
55
+ );
56
+ const restore = restoreDeploymentFiles(deps.projectWorkspaceDir(flags), body, {
57
+ force: options.force === true || deps.booleanFlag(flags, 'force'),
58
+ backupConflicts: options.backupConflicts === true,
59
+ });
60
+ const value = { ...body, files: undefined, restore };
61
+ if (options.output === false) return value;
62
+ deps.output(flags, value, (response) => {
63
+ console.log(`Deployment source: ${response.deployment_id || deploymentId}`);
64
+ console.log(`Files written: ${response.restore.files_written}`);
65
+ if (response.restore.backup_root) console.log(`Backup: ${response.restore.backup_root}`);
66
+ if (response.restore.protected_files_skipped.length) {
67
+ console.log(`Protected files skipped: ${response.restore.protected_files_skipped.length}`);
68
+ }
69
+ });
70
+ return value;
71
+ }
72
+
73
+ function restoreDeploymentFiles(workspaceDir, body, options = {}) {
74
+ ensureTokenIgnoreInvariant(workspaceDir);
75
+ const files = body && typeof body.files === 'object' && !Array.isArray(body.files) ? body.files : null;
76
+ if (!files) throw new Error('deployment source has no valid files');
77
+ const planned = [];
78
+ const protectedFiles = [];
79
+ for (const [fileName, content] of Object.entries(files)) {
80
+ const relative = safeProjectRelativePath(fileName);
81
+ if (deps.isProtectedProjectPath(relative)) protectedFiles.push(relative);
82
+ else planned.push([relative, String(content ?? '')]);
83
+ }
84
+ assertNonOverlappingFilePlan(planned.map(([relative]) => relative));
85
+ const conflictPaths = new Set();
86
+ const conflictingFiles = [];
87
+ for (const [relative, content] of planned) {
88
+ const location = resolveProjectFileTarget(workspaceDir, relative);
89
+ if (location.blockers.length) {
90
+ location.blockers.forEach((blocker) => conflictPaths.add(blocker));
91
+ conflictingFiles.push(relative);
92
+ } else if (fs.existsSync(location.target) && fs.readFileSync(location.target, 'utf8') !== content) {
93
+ conflictPaths.add(relative);
94
+ conflictingFiles.push(relative);
95
+ }
96
+ }
97
+ if (conflictPaths.size && !options.force && !options.backupConflicts) {
98
+ throw new Error(
99
+ `deployment source conflicts with local files: ${[...conflictPaths].join(', ')}; re-run with --force to back up and replace them`
100
+ );
101
+ }
102
+ let backupRoot = '';
103
+ let backedUp = [];
104
+ if (conflictPaths.size) {
105
+ backupRoot = createExternalBackupRoot(workspaceDir, 'deployment-pull');
106
+ backedUp = backupAndRemoveProjectPaths(workspaceDir, [...conflictPaths], backupRoot);
107
+ }
108
+ for (const [relative, content] of planned) {
109
+ const location = resolveProjectFileTarget(workspaceDir, relative);
110
+ if (location.blockers.length) {
111
+ throw new Error(
112
+ `deployment source target is blocked by a local path: ${location.blockers.join(', ')}`
113
+ );
114
+ }
115
+ deps.writeTextAtomically(location.target, content);
116
+ }
117
+ ensureTokenIgnoreInvariant(workspaceDir);
118
+ return {
119
+ files_written: planned.length,
120
+ conflicts_backed_up: backedUp,
121
+ conflicting_files: conflictingFiles,
122
+ backup_root: backupRoot || null,
123
+ protected_files_skipped: protectedFiles,
124
+ };
125
+ }
126
+
127
+ function ensureTokenIgnoreInvariant(workspaceDir) {
128
+ if (fs.existsSync(path.join(workspaceDir, '.env.joripspace'))) {
129
+ ensureProjectEnvIgnored(workspaceDir);
130
+ }
131
+ }
132
+
133
+ async function secrets(rest, flags) {
134
+ const subcommand = rest[0] || 'list';
135
+ if (subcommand === 'list') return listSecrets(flags);
136
+ if (subcommand === 'generate') return generateSecret(flags);
137
+ if (subcommand === 'set' || subcommand === 'delete') return deps.webOnlyCommand('외부 시크릿 값 관리');
138
+ throw new Error('secret command requires: list or generate');
139
+ }
140
+
141
+ async function generateSecret(flags) {
142
+ const project = deps.requireProjectId(flags);
143
+ const name = deps.stringFlag(flags, 'name');
144
+ if (!name) throw new Error('secret generate requires --name');
145
+ const body = await deps.apiRequest(
146
+ flags,
147
+ `/v1/projects/${encodeURIComponent(project)}/secrets/generate`,
148
+ {
149
+ method: 'POST',
150
+ ...deps.projectAuth(flags),
151
+ body: { name },
152
+ }
153
+ );
154
+ deps.output(flags, body, (value) => {
155
+ console.log(`Secret: ${value.name || name}`);
156
+ console.log(`Status: ${value.status || (value.generated ? 'generated' : 'preserved')}`);
157
+ });
158
+ }
159
+
160
+ async function listSecrets(flags) {
161
+ const project = deps.requireProjectId(flags);
162
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/secrets`, {
163
+ method: 'GET',
164
+ ...deps.projectAuth(flags),
165
+ });
166
+ deps.output(flags, body, (value) => {
167
+ for (const secret of value.secrets || []) {
168
+ console.log(`${secret.name}\tcreated=${secret.created_at}\tupdated=${secret.updated_at}`);
169
+ }
170
+ });
171
+ }
172
+
173
+ async function crons(rest, flags) {
174
+ const subcommand = rest[0] || 'list';
175
+ if (subcommand === 'list') return listCrons(flags);
176
+ if (subcommand === 'create') return createCron(flags);
177
+ if (subcommand === 'run') return runCron(flags);
178
+ if (subcommand === 'delete') return deleteCron(flags);
179
+ throw new Error('cron command requires: list, create, run, or delete');
180
+ }
181
+
182
+ async function listCrons(flags) {
183
+ const project = deps.requireProjectId(flags);
184
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/crons`, {
185
+ method: 'GET',
186
+ ...deps.projectAuth(flags),
187
+ });
188
+ deps.output(flags, body, (value) => {
189
+ for (const cron of value.crons || []) {
190
+ console.log(
191
+ `${cron.cron_id}\t${cron.name}\t${cron.schedule}\t${cron.method} ${cron.path}\tnext=${cron.next_run_at ?? 'none'}\tlast=${cron.last_run_at ?? 'never'}\tstatus=${cron.last_status ?? 'none'}`
192
+ );
193
+ }
194
+ });
195
+ }
196
+
197
+ async function createCron(flags) {
198
+ const project = deps.requireProjectId(flags);
199
+ const schedule = deps.stringFlag(flags, 'schedule');
200
+ const targetPath = deps.stringFlag(flags, 'path');
201
+ if (!schedule || !targetPath) throw new Error('cron create requires --schedule and --path');
202
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/crons`, {
203
+ method: 'POST',
204
+ ...deps.projectAuth(flags),
205
+ body: {
206
+ name: deps.stringFlag(flags, 'name') || undefined,
207
+ schedule,
208
+ path: targetPath,
209
+ method: deps.stringFlag(flags, 'method') || undefined,
210
+ },
211
+ });
212
+ deps.output(flags, body, (value) => {
213
+ console.log(`Cron: ${value.cron.cron_id}`);
214
+ console.log(`Name: ${value.cron.name}`);
215
+ console.log(`Schedule: ${value.cron.schedule}`);
216
+ console.log(`Target: ${value.cron.method} ${value.cron.path}`);
217
+ console.log(`Next run: ${value.cron.next_run_at}`);
218
+ });
219
+ }
220
+
221
+ async function runCron(flags) {
222
+ const project = deps.requireProjectId(flags);
223
+ const cronId = deps.stringFlag(flags, 'cron-id') || deps.stringFlag(flags, 'cron_id');
224
+ if (!cronId) throw new Error('cron run requires --cron-id');
225
+ const body = await deps.apiRequest(
226
+ flags,
227
+ `/v1/projects/${encodeURIComponent(project)}/crons/${encodeURIComponent(cronId)}/run`,
228
+ { method: 'POST', ...deps.projectAuth(flags) }
229
+ );
230
+ deps.output(flags, body, (value) => console.log(`${value.cron_id}: ${value.status}`));
231
+ }
232
+
233
+ async function deleteCron(flags) {
234
+ const project = deps.requireProjectId(flags);
235
+ const cronId = deps.stringFlag(flags, 'cron-id') || deps.stringFlag(flags, 'cron_id');
236
+ if (!cronId) throw new Error('cron delete requires --cron-id');
237
+ if (!deps.booleanFlag(flags, 'yes')) throw new Error('cron delete requires --yes');
238
+ const body = await deps.apiRequest(
239
+ flags,
240
+ `/v1/projects/${encodeURIComponent(project)}/crons/${encodeURIComponent(cronId)}`,
241
+ { method: 'DELETE', ...deps.projectAuth(flags) }
242
+ );
243
+ deps.output(flags, body, (value) => console.log(`${value.cron_id}: ${value.status}`));
244
+ }
245
+
246
+ async function domains(rest, flags) {
247
+ const subcommand = rest[0] || 'list';
248
+ if (subcommand === 'list') return listDomains(flags);
249
+ if (subcommand === 'create') return createDomain(flags);
250
+ if (subcommand === 'verify') return verifyDomain(flags);
251
+ if (subcommand === 'delete') return deleteDomain(flags);
252
+ throw new Error('domain command requires: list, create, verify, or delete');
253
+ }
254
+
255
+ async function listDomains(flags) {
256
+ const project = deps.requireProjectId(flags);
257
+ const params = new URLSearchParams();
258
+ const cursor = deps.stringFlag(flags, 'cursor');
259
+ const limit = deps.positiveIntegerFlag(flags, 'limit');
260
+ if (cursor) params.set('cursor', cursor);
261
+ if (limit) params.set('limit', String(limit));
262
+ const body = await deps.apiRequest(
263
+ flags,
264
+ `/v1/projects/${encodeURIComponent(project)}/domains${params.size ? `?${params}` : ''}`,
265
+ { method: 'GET', ...deps.projectAuth(flags) }
266
+ );
267
+ deps.output(flags, body, (value) => {
268
+ for (const domain of value.domains || []) printDomain(domain);
269
+ if (value.next_cursor) console.log(`Next cursor: ${value.next_cursor}`);
270
+ });
271
+ }
272
+
273
+ async function createDomain(flags) {
274
+ const project = deps.requireProjectId(flags);
275
+ const hostname = deps.stringFlag(flags, 'hostname') || deps.stringFlag(flags, 'domain');
276
+ if (!hostname) throw new Error('domain create requires --hostname');
277
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/domains`, {
278
+ method: 'POST',
279
+ ...deps.projectAuth(flags),
280
+ body: { hostname },
281
+ });
282
+ deps.output(flags, body, (value) => printDomain(value.domain));
283
+ }
284
+
285
+ async function verifyDomain(flags) {
286
+ const project = deps.requireProjectId(flags);
287
+ const hostname = deps.stringFlag(flags, 'hostname') || deps.stringFlag(flags, 'domain');
288
+ if (!hostname) throw new Error('domain verify requires --hostname');
289
+ const body = await deps.apiRequest(
290
+ flags,
291
+ `/v1/projects/${encodeURIComponent(project)}/domains/${encodeURIComponent(hostname)}/verify`,
292
+ { method: 'POST', ...deps.projectAuth(flags) }
293
+ );
294
+ deps.output(flags, body, (value) => printDomain(value.domain));
295
+ }
296
+
297
+ async function deleteDomain(flags) {
298
+ const project = deps.requireProjectId(flags);
299
+ const hostname = deps.stringFlag(flags, 'hostname') || deps.stringFlag(flags, 'domain');
300
+ if (!hostname) throw new Error('domain delete requires --hostname');
301
+ if (!deps.booleanFlag(flags, 'yes')) throw new Error('domain delete requires --yes');
302
+ const body = await deps.apiRequest(
303
+ flags,
304
+ `/v1/projects/${encodeURIComponent(project)}/domains/${encodeURIComponent(hostname)}`,
305
+ { method: 'DELETE', ...deps.projectAuth(flags) }
306
+ );
307
+ deps.output(flags, body, (value) => console.log(`${value.hostname}: ${value.status}`));
308
+ }
309
+
310
+ function printDomain(domain) {
311
+ console.log(`Domain: ${domain.hostname}`);
312
+ console.log(`Kind: ${domain.kind}`);
313
+ console.log(`Status: ${domain.status}`);
314
+ console.log(`Verification: ${domain.verification_status ?? 'none'}`);
315
+ console.log(`URL: ${domain.url}`);
316
+ if (domain.dns_target) console.log(`CNAME target: ${domain.dns_target}`);
317
+ if (domain.ownership_verification_name && domain.ownership_verification_value) {
318
+ console.log(
319
+ `TXT verification: ${domain.ownership_verification_name} = ${domain.ownership_verification_value}`
320
+ );
321
+ }
322
+ }
323
+
324
+ async function mail(rest, flags) {
325
+ const subcommand = rest[0] || 'status';
326
+ const project = deps.requireProjectId(flags);
327
+ if (subcommand === 'status') {
328
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/mail/status`, {
329
+ method: 'GET',
330
+ ...deps.projectAuth(flags),
331
+ });
332
+ deps.output(flags, body, (value) => {
333
+ const state = value.mail || value;
334
+ console.log(`Mail: ${state.status || (state.configured ? 'configured' : 'not configured')}`);
335
+ if (state.provider) console.log(`Provider: ${state.provider}`);
336
+ });
337
+ return;
338
+ }
339
+ if (subcommand === 'connect') {
340
+ const details = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}`, {
341
+ method: 'GET',
342
+ ...deps.projectAuth(flags),
343
+ });
344
+ const publicProject = details.project_slug || details.project_id || project;
345
+ const status = await deps.apiRequest(
346
+ flags,
347
+ `/v1/projects/${encodeURIComponent(publicProject)}/mail/status`,
348
+ { method: 'GET', ...deps.projectAuth(flags) }
349
+ );
350
+ const state = status.mail || status;
351
+ const body =
352
+ state.configured === true && state.status === 'connected'
353
+ ? { status: 'already_connected', project_id: publicProject, mail: state }
354
+ : state.google_oauth_setup_required === true
355
+ ? {
356
+ status: 'smtp_setup_available',
357
+ project_id: publicProject,
358
+ smtp_setup_url: `https://joripspace.com/projects/${encodeURIComponent(publicProject)}/?tab=mail`,
359
+ }
360
+ : {
361
+ status: 'browser_google_consent_required',
362
+ project_id: publicProject,
363
+ connect_url: `https://joripspace.com/projects/${encodeURIComponent(publicProject)}/mail/google/start/`,
364
+ };
365
+ deps.output(flags, body, (value) => {
366
+ console.log(`Mail connection: ${value.status}`);
367
+ if (value.smtp_setup_url) console.log(`SMTP setup: ${value.smtp_setup_url}`);
368
+ if (value.connect_url) console.log(`Google connection: ${value.connect_url}`);
369
+ });
370
+ return;
371
+ }
372
+ if (subcommand === 'test') {
373
+ const body = await deps.apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}/mail/test`, {
374
+ method: 'POST',
375
+ ...deps.projectAuth(flags),
376
+ body: {
377
+ to: deps.stringFlag(flags, 'to') || undefined,
378
+ subject: deps.stringFlag(flags, 'subject') || undefined,
379
+ },
380
+ });
381
+ deps.output(flags, body, (value) => console.log(`Test mail: ${value.status || 'sent'}`));
382
+ return;
383
+ }
384
+ throw new Error('mail command requires: connect, status, or test');
385
+ }
386
+
387
+ return {
388
+ crons,
389
+ deployment,
390
+ domains,
391
+ knowledge,
392
+ listCrons,
393
+ listDomains,
394
+ listSecrets,
395
+ mail,
396
+ pullDeploymentSource,
397
+ secrets,
398
+ };
399
+ }
400
+
401
+ module.exports = { createRemoteCommands };
@@ -0,0 +1,132 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const { resolveProjectRoot, startProject } = require('./start');
4
+ const { ensureProjectEnvIgnored, readProjectEnv } = require('./project-env');
5
+
6
+ function createStartProjectCommand(
7
+ apiRequest,
8
+ output,
9
+ resolveConnection,
10
+ stringFlag,
11
+ pullDeploymentSource,
12
+ projectWorkspaceDir,
13
+ persistConnection,
14
+ connectForStart
15
+ ) {
16
+ return async function startProjectCommand(rest, flags) {
17
+ const positionalProject = rest[0] || '';
18
+ const flaggedProject = stringFlag(flags, 'project');
19
+ if (positionalProject && flaggedProject && positionalProject !== flaggedProject) {
20
+ throw new Error('start positional project and --project must match');
21
+ }
22
+ const project = flaggedProject || positionalProject;
23
+ if (!project) throw new Error('start requires PROJECT');
24
+ if (rest.length > 1) throw new Error('start accepts exactly one PROJECT');
25
+ const requestedCwd = stringFlag(flags, 'cwd')
26
+ ? path.resolve(stringFlag(flags, 'cwd'))
27
+ : projectWorkspaceDir(flags);
28
+ const cwd = resolveProjectRoot(requestedCwd, 'git');
29
+ readProjectEnv(cwd);
30
+ if (fs.existsSync(path.join(cwd, '.env.joripspace'))) {
31
+ ensureProjectEnvIgnored(cwd);
32
+ }
33
+ const executable = path.resolve(
34
+ process.env.JORIPSPACE_CLI_EXECUTABLE ||
35
+ (process.pkg ? process.execPath : process.argv[1] || process.execPath)
36
+ );
37
+ const resolvedFlags = { ...flags, cwd };
38
+ let connection = resolveConnection(resolvedFlags);
39
+ if (!connection.apiToken) {
40
+ connection = connectForStart
41
+ ? await connectForStart(resolvedFlags, { cwd, executable, project })
42
+ : connection;
43
+ }
44
+ if (!connection?.apiToken) {
45
+ const apiUrlArgument = connection?.apiBaseUrl
46
+ ? ` --api-url ${quoteCliArgument(connection.apiBaseUrl)}`
47
+ : '';
48
+ const invocation = `${!process.pkg && executable === path.resolve(process.argv[1] || '') ? quoteCliArgument(process.execPath) + ' ' : ''}${quoteCliArgument(executable)}`;
49
+ const loginCommand = `${invocation} login --code "CONNECTION_CODE" --cwd ${quoteCliArgument(cwd)}${apiUrlArgument} --json`;
50
+ const resumeCommand = `${invocation} start ${quoteCliArgument(project)} --cwd ${quoteCliArgument(cwd)} --json`;
51
+ const value = {
52
+ ok: false,
53
+ status: 'connection_required',
54
+ project,
55
+ cwd,
56
+ executable,
57
+ connect_url: 'https://joripspace.com/connect/',
58
+ message: '브라우저에서 연결을 승인하고 표시된 5분 일회용 연결 코드를 먼저 교환하세요.',
59
+ login_command: loginCommand,
60
+ resume_command: resumeCommand,
61
+ next_action: 'run-login-command-then-resume-command',
62
+ continue_with: 'cli',
63
+ };
64
+ throw startCommandError(value.status, value.message, value);
65
+ }
66
+ const apiToken = connection.apiToken;
67
+ const connectionFlags = {
68
+ ...flags,
69
+ cwd,
70
+ 'api-token': connection.apiToken,
71
+ 'api-url': connection.apiBaseUrl,
72
+ };
73
+
74
+ const value = await startProject({
75
+ projectId: project,
76
+ cwd,
77
+ apiToken,
78
+ apiRequest: (apiPath, options) => apiRequest(connectionFlags, apiPath, options),
79
+ executable,
80
+ allowLegacyCredentialSession: connection.source === 'legacy-project-session',
81
+ beforeWorkspaceMigration: persistConnection
82
+ ? () => persistConnection(resolvedFlags, connection)
83
+ : undefined,
84
+ });
85
+ if (value.ok && value.context?.source_sync?.status === 'latest_deployment_restore_required') {
86
+ const deploymentId = value.context.source_sync.deployment_id;
87
+ const deploymentRestore = await pullDeploymentSource(
88
+ { ...connectionFlags, project: value.project, deployment: deploymentId },
89
+ { output: false, backupConflicts: true }
90
+ );
91
+ value.context.source_sync = {
92
+ status: 'synchronized',
93
+ operation: 'deployment_restore',
94
+ deployment_id: deploymentId,
95
+ restore: deploymentRestore.restore,
96
+ };
97
+ }
98
+ if (!value.ok) {
99
+ throw startCommandError(
100
+ value.status || 'start_incomplete',
101
+ `JoripSpace start stopped: ${value.status || 'incomplete'}`,
102
+ value
103
+ );
104
+ }
105
+ output(flags, value, (result) => {
106
+ console.log(`Started project: ${result.project}`);
107
+ console.log(`CLI: ${result.executable}`);
108
+ console.log('Session transport: CLI');
109
+ console.log(`Next action: ${result.next_action}`);
110
+ if (result.template_choice?.status === 'ready') {
111
+ console.log(`Templates: ${result.template_choice.templates.length} available plus no-template option`);
112
+ }
113
+ if (result.context?.source_sync?.operation === 'deployment_restore') {
114
+ console.log('Latest deployment source restored with conflict backups.');
115
+ }
116
+ });
117
+ };
118
+ }
119
+
120
+ function startCommandError(code, message, details) {
121
+ const error = new Error(message);
122
+ error.code = code;
123
+ error.exitCode = 2;
124
+ error.details = details;
125
+ return error;
126
+ }
127
+
128
+ function quoteCliArgument(value) {
129
+ return `"${String(value).replace(/"/g, '\\"')}"`;
130
+ }
131
+
132
+ module.exports = { createStartProjectCommand };