@joripspace/cli 0.6.1 → 0.8.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.
- package/LICENSE +21 -21
- package/README.md +82 -8
- package/THIRD_PARTY_NOTICES.md +136 -136
- package/bin/joripspace.js +51 -163
- package/lib/approval-login.js +88 -0
- package/lib/connection-persistence.js +1 -1
- package/lib/credential-store.js +2 -2
- package/lib/deploy-prepare.js +48 -0
- package/lib/deployment-error.js +14 -14
- package/lib/help.js +23 -15
- package/lib/login-command.js +19 -0
- package/lib/project-create.js +1 -1
- package/lib/secret-commands.js +5 -5
- package/lib/start-command.js +5 -6
- package/lib/start.js +1507 -1507
- package/package.json +1 -1
- package/vendor/core/cli-onboarding.cjs +13 -9
- package/vendor/core/onboarding.cjs +26 -29
- package/vendor/core/secret-entry.cjs +38 -0
- package/vendor/core/template-publish-workflow.cjs +169 -169
- package/vendor/templates/index.js +104 -104
- package/vendor/templates/templates/basic-worker/files/worker.js +9 -9
- package/vendor/templates/templates/basic-worker/manifest.json +14 -14
- package/vendor/templates/templates/r2-file-api/files/worker.js +42 -42
- package/vendor/templates/templates/r2-file-api/manifest.json +7 -7
package/bin/joripspace.js
CHANGED
|
@@ -6,7 +6,6 @@ const fs = require('node:fs');
|
|
|
6
6
|
const os = require('node:os');
|
|
7
7
|
const path = require('node:path');
|
|
8
8
|
const { spawn } = require('node:child_process');
|
|
9
|
-
const readline = require('node:readline/promises');
|
|
10
9
|
const { formatDeploymentFailure } = require('../lib/deployment-error');
|
|
11
10
|
const {
|
|
12
11
|
printHelp,
|
|
@@ -40,6 +39,16 @@ const { createCredentialStore, normalizeCredentialApiUrl } = require('../lib/cre
|
|
|
40
39
|
const credentialStore = createCredentialStore();
|
|
41
40
|
const { persistProjectConnection } = require('../lib/connection-persistence');
|
|
42
41
|
const { createStartProjectCommand } = require('../lib/start-command');
|
|
42
|
+
const { createApprovalLogin } = require('../lib/approval-login');
|
|
43
|
+
const { createLoginCommand } = require('../lib/login-command');
|
|
44
|
+
const approvalLogin = createApprovalLogin({
|
|
45
|
+
apiRequest,
|
|
46
|
+
openExternalUrl,
|
|
47
|
+
saveToken: (flags, token, apiBaseUrl, options) => saveBrowserConnectTokenWithOptions(
|
|
48
|
+
flags, normalizeConnectToken(token), 'approval-link', apiBaseUrl, options
|
|
49
|
+
),
|
|
50
|
+
});
|
|
51
|
+
const login = createLoginCommand({ ensureProjectEnvIgnored, projectWorkspaceDir, stringFlag, normalizeCredentialApiUrl, unauthenticatedApiBaseUrl, normalizeConnectToken, saveBrowserConnectToken, resolveConnection, approvalLogin });
|
|
43
52
|
const { legacyCredentialSessionConnection, readProjectMarker } = require('../lib/start');
|
|
44
53
|
const { buildTemplateDeployRequest, listTemplates } = loadTemplatesPackage();
|
|
45
54
|
const templateCommands = createTemplateCommands({
|
|
@@ -152,8 +161,8 @@ async function main() {
|
|
|
152
161
|
return;
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
if (command === 'report' && (flags.help || flags.h)) {
|
|
156
|
-
printReportHelp();
|
|
164
|
+
if ((command === 'report' || command === 'feedback') && (flags.help || flags.h)) {
|
|
165
|
+
printReportHelp(command);
|
|
157
166
|
return;
|
|
158
167
|
}
|
|
159
168
|
|
|
@@ -207,6 +216,9 @@ async function main() {
|
|
|
207
216
|
case 'report':
|
|
208
217
|
await reportAgentIssue(flags);
|
|
209
218
|
return;
|
|
219
|
+
case 'feedback':
|
|
220
|
+
await reportAgentIssue({ ...flags, category: 'feedback' });
|
|
221
|
+
return;
|
|
210
222
|
case 'db':
|
|
211
223
|
await dbCommand(rest, flags);
|
|
212
224
|
return;
|
|
@@ -218,6 +230,23 @@ async function main() {
|
|
|
218
230
|
printDeployHelp();
|
|
219
231
|
return;
|
|
220
232
|
}
|
|
233
|
+
if (flags.prepare) {
|
|
234
|
+
const project = requireProjectId(flags);
|
|
235
|
+
const details = await apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}`, {
|
|
236
|
+
method: 'GET',
|
|
237
|
+
...projectAuth(flags),
|
|
238
|
+
});
|
|
239
|
+
if (details?.deployment?.mode === 'github_actions') {
|
|
240
|
+
throw new Error('GitHub deployment is connected: use its configured workflow and trigger');
|
|
241
|
+
}
|
|
242
|
+
const result = require('../lib/deploy-prepare').prepareDeployment(
|
|
243
|
+
projectWorkspaceDir(flags),
|
|
244
|
+
flags,
|
|
245
|
+
writeTextAtomically
|
|
246
|
+
);
|
|
247
|
+
output(flags, result, (value) => console.log(value.next_action));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
221
250
|
await deployCode(flags);
|
|
222
251
|
return;
|
|
223
252
|
case 'templates':
|
|
@@ -331,50 +360,6 @@ async function main() {
|
|
|
331
360
|
}
|
|
332
361
|
}
|
|
333
362
|
|
|
334
|
-
async function login(flags) {
|
|
335
|
-
const connectionCode = stringFlag(flags, 'code');
|
|
336
|
-
if (connectionCode) {
|
|
337
|
-
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
338
|
-
const exchangeApiBaseUrl = normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags));
|
|
339
|
-
const exchange = await apiRequest(flags, '/v1/auth/connection-code/exchange', {
|
|
340
|
-
method: 'POST',
|
|
341
|
-
body: { code: normalizeConnectionCode(connectionCode) },
|
|
342
|
-
apiBaseUrl: exchangeApiBaseUrl,
|
|
343
|
-
});
|
|
344
|
-
const exchangedToken = normalizeConnectToken(exchange.connect_token);
|
|
345
|
-
await saveBrowserConnectToken(flags, exchangedToken, 'connection-code', exchangeApiBaseUrl);
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
const connectToken =
|
|
349
|
-
stringFlag(flags, 'connect-token') || stringFlag(flags, 'api-token') || stringFlag(flags, 'token');
|
|
350
|
-
if (connectToken) {
|
|
351
|
-
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
352
|
-
await saveBrowserConnectToken(flags, normalizeConnectToken(connectToken));
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
let existing;
|
|
356
|
-
try {
|
|
357
|
-
existing = resolveConnection(flags);
|
|
358
|
-
} catch (error) {
|
|
359
|
-
if (error.code !== 'credential_store_unavailable') throw error;
|
|
360
|
-
// Reauthentication can obtain a new token even when an older OS login is inaccessible.
|
|
361
|
-
}
|
|
362
|
-
if (existing?.apiToken) {
|
|
363
|
-
await saveBrowserConnectToken(
|
|
364
|
-
flags,
|
|
365
|
-
normalizeConnectToken(existing.apiToken),
|
|
366
|
-
existing.source,
|
|
367
|
-
existing.apiBaseUrl
|
|
368
|
-
);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const enteredCode = await promptConnectionCode(flags);
|
|
372
|
-
if (enteredCode !== null) {
|
|
373
|
-
await login({ ...flags, code: normalizeConnectionCode(enteredCode) });
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
output(flags, browserConnectInstructions(), printBrowserConnectInstructions);
|
|
377
|
-
}
|
|
378
363
|
|
|
379
364
|
async function saveBrowserConnectToken(flags, apiToken, source = 'browser-connect', selectedApiBaseUrl = '') {
|
|
380
365
|
return saveBrowserConnectTokenWithOptions(flags, apiToken, source, selectedApiBaseUrl);
|
|
@@ -486,7 +471,17 @@ async function saveBrowserConnectTokenWithOptions(
|
|
|
486
471
|
const storage = persistProjectConnection(credentialStore, workspaceDir, { ...connection, accountId: body.account_id });
|
|
487
472
|
scrubGlobalSessionToken();
|
|
488
473
|
if (options.output !== false) {
|
|
489
|
-
|
|
474
|
+
const next = {
|
|
475
|
+
status: 'connected',
|
|
476
|
+
next_action: selected ? 'run_start_project' : 'choose_project_then_run_start',
|
|
477
|
+
...(selected ? { next_command: {
|
|
478
|
+
command: process.execPath,
|
|
479
|
+
args: [...(process.pkg ? [] : [path.resolve(process.argv[1])]), 'start', selected.project_slug || selected.project_id,
|
|
480
|
+
'--cwd', workspaceDir, '--api-url', connection.apiBaseUrl, '--json'],
|
|
481
|
+
cwd: workspaceDir,
|
|
482
|
+
} } : {}),
|
|
483
|
+
};
|
|
484
|
+
output(flags, { ...body, credential_storage: storage, ...next }, (value) => {
|
|
490
485
|
console.log(message(`Connected: ${value.account_id}`, `연결 완료: ${value.account_id}`));
|
|
491
486
|
console.log(
|
|
492
487
|
storage === 'project-env-fallback' ? message(
|
|
@@ -1183,6 +1178,7 @@ async function apiRequest(flags, apiPath, options) {
|
|
|
1183
1178
|
options.apiToken,
|
|
1184
1179
|
options.adminToken,
|
|
1185
1180
|
options.body?.code,
|
|
1181
|
+
options.body?.request_secret,
|
|
1186
1182
|
])
|
|
1187
1183
|
);
|
|
1188
1184
|
requestError.code = 'request_failed';
|
|
@@ -1194,7 +1190,7 @@ async function apiRequest(flags, apiPath, options) {
|
|
|
1194
1190
|
const body = text ? parseJson(text) : {};
|
|
1195
1191
|
|
|
1196
1192
|
if (!response.ok) {
|
|
1197
|
-
const safe = redactAuthError(body, [options.apiToken, options.adminToken, options.body?.code]);
|
|
1193
|
+
const safe = redactAuthError(body, [options.apiToken, options.adminToken, options.body?.code, options.body?.request_secret]);
|
|
1198
1194
|
const message =
|
|
1199
1195
|
safe?.error?.message || safe?.message || JSON.stringify(safe) || `HTTP ${response.status}`;
|
|
1200
1196
|
const apiError = new Error(formatDeploymentFailure(message, safe?.error?.details));
|
|
@@ -1219,41 +1215,6 @@ function isDeploymentMutation(apiPath, method) {
|
|
|
1219
1215
|
return method === 'POST' && (/\/deploy(?:[/?]|$)/.test(apiPath) || /\/rollback(?:[/?]|$)/.test(apiPath));
|
|
1220
1216
|
}
|
|
1221
1217
|
|
|
1222
|
-
function browserConnectInstructions() {
|
|
1223
|
-
return {
|
|
1224
|
-
status: 'browser_connection_required',
|
|
1225
|
-
connect_url: 'https://joripspace.com/connect/',
|
|
1226
|
-
message: message(
|
|
1227
|
-
'No email address is required. Sign in to JoripSpace in your browser, approve the connection, and copy the one-time code, valid for five minutes.',
|
|
1228
|
-
'이메일 주소는 필요 없습니다. 브라우저에서 JoripSpace에 로그인한 뒤 연결을 승인하고 5분 일회용 연결 코드를 복사하세요.'
|
|
1229
|
-
),
|
|
1230
|
-
save_command: 'joripspace login --code "CONNECTION_CODE"',
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
function printBrowserConnectInstructions(value) {
|
|
1235
|
-
console.log(
|
|
1236
|
-
message(
|
|
1237
|
-
'Approve the JoripSpace connection in your browser.',
|
|
1238
|
-
'브라우저에서 JoripSpace 연결을 승인하세요.'
|
|
1239
|
-
)
|
|
1240
|
-
);
|
|
1241
|
-
console.log(
|
|
1242
|
-
message(
|
|
1243
|
-
'No email address or email verification is required.',
|
|
1244
|
-
'이메일 주소 입력이나 메일 확인은 필요 없습니다.'
|
|
1245
|
-
)
|
|
1246
|
-
);
|
|
1247
|
-
console.log(message(`Connection page: ${value.connect_url}`, `연결 페이지: ${value.connect_url}`));
|
|
1248
|
-
console.log(
|
|
1249
|
-
message(
|
|
1250
|
-
'After approval, exchange the displayed five-minute one-time code using this command.',
|
|
1251
|
-
'승인 후 화면에 표시되는 5분 일회용 연결 코드를 아래 명령으로 교환하세요.'
|
|
1252
|
-
)
|
|
1253
|
-
);
|
|
1254
|
-
console.log(value.save_command);
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
1218
|
function normalizeConnectToken(value) {
|
|
1258
1219
|
const token = String(value || '').trim();
|
|
1259
1220
|
if (!token) {
|
|
@@ -1267,29 +1228,14 @@ function normalizeConnectToken(value) {
|
|
|
1267
1228
|
) {
|
|
1268
1229
|
throw new Error(
|
|
1269
1230
|
message(
|
|
1270
|
-
'Browser cookies, Bearer strings, empty placeholders, and test values cannot be used as CLI connection tokens.
|
|
1271
|
-
'브라우저 쿠키, Bearer 문자열, 빈 자리표시자, 테스트 값은 CLI 연결 토큰으로 사용할 수 없습니다.
|
|
1231
|
+
'Browser cookies, Bearer strings, empty placeholders, and test values cannot be used as CLI connection tokens. Run login to approve a new connection.',
|
|
1232
|
+
'브라우저 쿠키, Bearer 문자열, 빈 자리표시자, 테스트 값은 CLI 연결 토큰으로 사용할 수 없습니다. login을 실행해 새 연결을 승인하세요.'
|
|
1272
1233
|
)
|
|
1273
1234
|
);
|
|
1274
1235
|
}
|
|
1275
1236
|
return token;
|
|
1276
1237
|
}
|
|
1277
1238
|
|
|
1278
|
-
function normalizeConnectionCode(value) {
|
|
1279
|
-
const normalized = String(value || '')
|
|
1280
|
-
.replace(/[\s-]+/g, '')
|
|
1281
|
-
.toUpperCase();
|
|
1282
|
-
if (!/^[0-9A-HJKMNP-TV-Z]{16}$/.test(normalized)) {
|
|
1283
|
-
throw new Error(
|
|
1284
|
-
message(
|
|
1285
|
-
'The connection code must be the 16-character alphanumeric value shown on the connection page.',
|
|
1286
|
-
'연결 코드는 화면에 표시된 16자리 영숫자 값이어야 합니다.'
|
|
1287
|
-
)
|
|
1288
|
-
);
|
|
1289
|
-
}
|
|
1290
|
-
return normalized.match(/.{1,4}/g).join('-');
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
1239
|
function parseArgs(argv) {
|
|
1294
1240
|
const flags = {};
|
|
1295
1241
|
const positional = [];
|
|
@@ -1612,72 +1558,14 @@ function canonicalWorkspaceEntry(directory, expected) {
|
|
|
1612
1558
|
}
|
|
1613
1559
|
|
|
1614
1560
|
async function connectForStart(flags, context) {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
connectionCode = await promptConnectionCode(flags);
|
|
1618
|
-
if (connectionCode === null) return resolveConnection(flags);
|
|
1561
|
+
if (flags.code !== undefined || flags['legacy-code'] !== undefined) {
|
|
1562
|
+
throw Object.assign(new Error('Run login to approve the connection in your browser.'), { code: 'unsupported_login_option' });
|
|
1619
1563
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
ensureProjectEnvIgnored(context.cwd);
|
|
1623
|
-
const exchange = await apiRequest(flags, '/v1/auth/connection-code/exchange', {
|
|
1624
|
-
method: 'POST',
|
|
1625
|
-
body: { code: normalizeConnectionCode(connectionCode) },
|
|
1626
|
-
apiBaseUrl: exchangeApiBaseUrl,
|
|
1627
|
-
});
|
|
1628
|
-
const exchangedToken = normalizeConnectToken(exchange.connect_token);
|
|
1629
|
-
await saveBrowserConnectTokenWithOptions(
|
|
1630
|
-
{ ...flags, cwd: context.cwd },
|
|
1631
|
-
exchangedToken,
|
|
1632
|
-
'connection-code',
|
|
1633
|
-
exchangeApiBaseUrl,
|
|
1634
|
-
{ output: false }
|
|
1635
|
-
);
|
|
1564
|
+
if (flags.json || !process.stdin.isTTY || !process.stdout.isTTY) return resolveConnection(flags);
|
|
1565
|
+
await approvalLogin.login({ ...flags, cwd: context.cwd }, normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags)), { output: false });
|
|
1636
1566
|
return resolveConnection({ ...flags, cwd: context.cwd });
|
|
1637
1567
|
}
|
|
1638
1568
|
|
|
1639
|
-
async function promptConnectionCode(flags) {
|
|
1640
|
-
if (flags.json || !process.stdin.isTTY || !process.stdout.isTTY) return null;
|
|
1641
|
-
const instructions = browserConnectInstructions();
|
|
1642
|
-
console.log(
|
|
1643
|
-
message(
|
|
1644
|
-
'Approve the JoripSpace connection in your browser.',
|
|
1645
|
-
'브라우저에서 JoripSpace 연결을 승인하세요.'
|
|
1646
|
-
)
|
|
1647
|
-
);
|
|
1648
|
-
console.log(
|
|
1649
|
-
message(`Connection page: ${instructions.connect_url}`, `연결 페이지: ${instructions.connect_url}`)
|
|
1650
|
-
);
|
|
1651
|
-
console.log(
|
|
1652
|
-
message(
|
|
1653
|
-
'After approval, paste the displayed five-minute one-time code into this terminal.',
|
|
1654
|
-
'승인 후 표시된 5분 일회용 연결 코드를 이 터미널에 붙여 넣으세요.'
|
|
1655
|
-
)
|
|
1656
|
-
);
|
|
1657
|
-
openExternalUrl(instructions.connect_url);
|
|
1658
|
-
const prompt = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1659
|
-
const cancellation = new AbortController();
|
|
1660
|
-
prompt.once('close', () => cancellation.abort());
|
|
1661
|
-
try {
|
|
1662
|
-
return await prompt.question(message('Connection code: ', '연결 코드: '), {
|
|
1663
|
-
signal: cancellation.signal,
|
|
1664
|
-
});
|
|
1665
|
-
} catch (error) {
|
|
1666
|
-
if (error?.code !== 'ABORT_ERR') throw error;
|
|
1667
|
-
const cancelled = new Error(
|
|
1668
|
-
message(
|
|
1669
|
-
'Connection code entry was cancelled. Run login again.',
|
|
1670
|
-
'연결 코드 입력이 취소되었습니다. login을 다시 실행하세요.'
|
|
1671
|
-
)
|
|
1672
|
-
);
|
|
1673
|
-
cancelled.code = 'connection_required';
|
|
1674
|
-
cancelled.exitCode = 2;
|
|
1675
|
-
throw cancelled;
|
|
1676
|
-
} finally {
|
|
1677
|
-
prompt.close();
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
1569
|
function openExternalUrl(url) {
|
|
1682
1570
|
const command =
|
|
1683
1571
|
process.platform === 'win32'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const { message } = require('./locale');
|
|
2
|
+
|
|
3
|
+
function createApprovalLogin({
|
|
4
|
+
apiRequest,
|
|
5
|
+
openExternalUrl,
|
|
6
|
+
saveToken,
|
|
7
|
+
writePending = (value) => console.error(JSON.stringify(value)),
|
|
8
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
9
|
+
}) {
|
|
10
|
+
async function supported(flags, apiBaseUrl) {
|
|
11
|
+
try {
|
|
12
|
+
const result = await apiRequest(flags, '/v1/auth/approval-link/capabilities', {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
apiBaseUrl,
|
|
15
|
+
});
|
|
16
|
+
return result.approval_link === true && result.version === 1;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if ([404, 405].includes(error.status)) return false;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function login(flags, apiBaseUrl, { output = true } = {}) {
|
|
23
|
+
if (!(await supported(flags, apiBaseUrl))) throw Object.assign(new Error('This server does not support approval-link login. Update the server before reconnecting.'), { code: 'approval_link_unsupported' });
|
|
24
|
+
const request = await apiRequest(flags, '/v1/auth/approval-link/requests', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
apiBaseUrl,
|
|
27
|
+
body: { client: 'cli' },
|
|
28
|
+
});
|
|
29
|
+
const url = new URL(request.approval_url);
|
|
30
|
+
if (
|
|
31
|
+
url.href !== `https://joripspace.com/connect/device/?request=${request.request_id}` ||
|
|
32
|
+
url.searchParams.get('request') !== request.request_id ||
|
|
33
|
+
!/^[A-Za-z0-9_-]{32,128}$/.test(request.request_id || '') ||
|
|
34
|
+
!/^[A-Za-z0-9_-]{32,128}$/.test(request.request_secret || '') ||
|
|
35
|
+
!Number.isFinite(Date.parse(request.expires_at)) ||
|
|
36
|
+
Date.parse(request.expires_at) > Date.now() + 310000
|
|
37
|
+
) {
|
|
38
|
+
throw new Error('Invalid approval-link response.');
|
|
39
|
+
}
|
|
40
|
+
// Only the public URL leaves this process. The polling secret stays in memory.
|
|
41
|
+
writePending({
|
|
42
|
+
status: 'approval_pending',
|
|
43
|
+
approval_url: url.href,
|
|
44
|
+
expires_at: request.expires_at,
|
|
45
|
+
next_action: 'ask_user_to_approve_then_wait',
|
|
46
|
+
interval: 5,
|
|
47
|
+
message: message(
|
|
48
|
+
'Open the link and approve the connection. No code entry is needed.',
|
|
49
|
+
'링크를 열어 연결을 승인하세요. 코드 입력은 필요하지 않습니다.'
|
|
50
|
+
),
|
|
51
|
+
});
|
|
52
|
+
if (!flags['no-open']) openExternalUrl(url.href);
|
|
53
|
+
while (Date.now() < Date.parse(request.expires_at)) {
|
|
54
|
+
const result = await apiRequest(flags, '/v1/auth/approval-link/status', {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
apiBaseUrl,
|
|
57
|
+
body: { request_id: request.request_id, request_secret: request.request_secret },
|
|
58
|
+
});
|
|
59
|
+
if (result.status === 'connected') {
|
|
60
|
+
await saveToken(flags, result.connect_token, apiBaseUrl, { output });
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (result.status !== 'pending') {
|
|
64
|
+
const error = new Error(
|
|
65
|
+
message(
|
|
66
|
+
`Connection approval ${result.status}. Run login to try again.`,
|
|
67
|
+
`연결 승인 상태: ${result.status}. 다시 시도하려면 login을 실행하세요.`
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
error.code = `approval_${result.status}`;
|
|
71
|
+
error.details = { status: result.status, next_action: 'stop_and_report_approval_result' };
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
await sleep(Math.max(5, Math.min(30, Number(result.interval) || 5)) * 1000);
|
|
75
|
+
}
|
|
76
|
+
const error = new Error(
|
|
77
|
+
message(
|
|
78
|
+
'The connection approval link expired. Run login again.',
|
|
79
|
+
'연결 승인 링크가 만료되었습니다. login을 다시 실행하세요.'
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
error.code = 'approval_expired';
|
|
83
|
+
error.details = { status: 'expired', next_action: 'ask_user_before_starting_new_approval' };
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
return { supported, login };
|
|
87
|
+
}
|
|
88
|
+
module.exports = { createApprovalLogin };
|
|
@@ -7,7 +7,7 @@ function persistProjectConnection(store, workspaceDir, connection) {
|
|
|
7
7
|
const apiBaseUrl = normalizeCredentialApiUrl(connection.apiBaseUrl);
|
|
8
8
|
if (!connection.accountId || typeof connection.accountId !== 'string' ||
|
|
9
9
|
typeof connection.apiToken !== 'string' || !connection.apiToken.trim() || /[\r\n]/.test(connection.apiToken)) {
|
|
10
|
-
const error = new Error('Invalid connection credentials. Reconnect with login
|
|
10
|
+
const error = new Error('Invalid connection credentials. Reconnect with login.');
|
|
11
11
|
error.code = 'credential_store_invalid';
|
|
12
12
|
throw error;
|
|
13
13
|
}
|
package/lib/credential-store.js
CHANGED
|
@@ -7,8 +7,8 @@ function storeError(code = 'credential_store_unavailable') {
|
|
|
7
7
|
const error = new Error(
|
|
8
8
|
code === 'credential_store_invalid'
|
|
9
9
|
? message(
|
|
10
|
-
'The JoripSpace connection in the OS credential store is invalid. Reconnect with login
|
|
11
|
-
'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login
|
|
10
|
+
'The JoripSpace connection in the OS credential store is invalid. Reconnect with login.',
|
|
11
|
+
'OS 보안 저장소의 JoripSpace 연결 정보가 올바르지 않습니다. login로 다시 연결하세요.'
|
|
12
12
|
)
|
|
13
13
|
: message(
|
|
14
14
|
'The OS credential store could not complete this operation. Check Windows Credential Manager, macOS Keychain, or Linux Secret Service. Login uses .env.joripspace only when the store is unavailable before writing; failed writes or verification are not bypassed.',
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { resolveProjectFileTarget } = require('./project-paths');
|
|
4
|
+
const { buildDeployPayload } = require('./deploy-files');
|
|
5
|
+
|
|
6
|
+
// Preparation validates the actual build output, but never uploads or deploys it.
|
|
7
|
+
function prepareDeployment(workspace, flags, writeTextAtomically) {
|
|
8
|
+
const dir = String(flags.dir || '');
|
|
9
|
+
const entrypoint = String(flags.entrypoint || '');
|
|
10
|
+
for (const value of [dir, entrypoint]) {
|
|
11
|
+
if (!value || !/^[a-zA-Z0-9_./ -]+$/.test(value) || value.startsWith('-')) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
'deploy --prepare requires project-relative --dir and --entrypoint (letters, digits, spaces, _, -, ., /)'
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const outputLocation = resolveProjectFileTarget(workspace, `${dir}/${entrypoint}`);
|
|
18
|
+
if (outputLocation.blockers.length || !fs.existsSync(outputLocation.target)) {
|
|
19
|
+
throw new Error('Build the project first: the configured Worker entrypoint does not exist');
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
buildDeployPayload({ ...flags, cwd: workspace, dir: path.resolve(workspace, dir), entrypoint });
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code !== 'archive_required') throw error;
|
|
25
|
+
}
|
|
26
|
+
const location = resolveProjectFileTarget(workspace, 'package.json');
|
|
27
|
+
if (location.blockers.length) throw new Error('package.json path is blocked');
|
|
28
|
+
const pkg = JSON.parse(fs.readFileSync(location.target, 'utf8'));
|
|
29
|
+
if (pkg.scripts != null && (typeof pkg.scripts !== 'object' || Array.isArray(pkg.scripts))) {
|
|
30
|
+
throw new Error('package.json scripts must be an object');
|
|
31
|
+
}
|
|
32
|
+
const scripts = pkg.scripts || {};
|
|
33
|
+
const command = `${typeof scripts.build === 'string' ? 'npm run build && ' : ''}npx --yes @joripspace/cli@latest deploy --cwd . --dir "${dir}" --entrypoint "${entrypoint}"`;
|
|
34
|
+
if (scripts['joripspace:deploy'] && scripts['joripspace:deploy'] !== command) {
|
|
35
|
+
throw new Error('Existing joripspace:deploy script was preserved; review it before preparing deployment');
|
|
36
|
+
}
|
|
37
|
+
pkg.scripts = { ...scripts, 'joripspace:deploy': command };
|
|
38
|
+
writeTextAtomically(location.target, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
39
|
+
return {
|
|
40
|
+
status: 'prepared',
|
|
41
|
+
script: 'joripspace:deploy',
|
|
42
|
+
command,
|
|
43
|
+
next_action: 'npm run joripspace:deploy -- --label "배포 변경 내용"',
|
|
44
|
+
deployed: false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { prepareDeployment };
|
package/lib/deployment-error.js
CHANGED
|
@@ -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 };
|
package/lib/help.js
CHANGED
|
@@ -6,8 +6,7 @@ function printHelp() {
|
|
|
6
6
|
|
|
7
7
|
Usage:
|
|
8
8
|
joripspace login
|
|
9
|
-
joripspace login --
|
|
10
|
-
joripspace login --connect-token "CONNECTION_TOKEN" --cwd PROJECT_FOLDER
|
|
9
|
+
joripspace login --no-open --cwd PROJECT_FOLDER --json
|
|
11
10
|
joripspace logout
|
|
12
11
|
joripspace me
|
|
13
12
|
joripspace projects
|
|
@@ -42,6 +41,7 @@ Usage:
|
|
|
42
41
|
joripspace template pull --project PROJECT --token TOKEN --dir . [--yes]
|
|
43
42
|
joripspace get --project PROJECT --token TOKEN
|
|
44
43
|
joripspace report --project PROJECT --category problem|bug|feedback --summary "REPORT_SUMMARY" [--details TEXT] [--expected TEXT] [--actual TEXT] [--error-code CODE]
|
|
44
|
+
joripspace feedback --project PROJECT --summary "FEEDBACK_SUMMARY" [--details TEXT] [--expected TEXT] [--actual TEXT] [--error-code CODE]
|
|
45
45
|
joripspace deployments --project PROJECT --token TOKEN [--include-failure-details] [--json]
|
|
46
46
|
joripspace deployment get --project PROJECT --deployment DEPLOYMENT_ID --json
|
|
47
47
|
joripspace deployment pull --project PROJECT --deployment DEPLOYMENT_ID --cwd PATH [--force]
|
|
@@ -55,6 +55,7 @@ Usage:
|
|
|
55
55
|
joripspace rollback --project PROJECT --token TOKEN --deployment DEPLOYMENT_ID
|
|
56
56
|
joripspace secrets --project PROJECT
|
|
57
57
|
joripspace secret list --project PROJECT
|
|
58
|
+
joripspace secret list --project PROJECT --name API_KEY --json
|
|
58
59
|
joripspace secret generate --project PROJECT --name SESSION_SECRET
|
|
59
60
|
joripspace secret set --project PROJECT --name API_KEY --value-stdin
|
|
60
61
|
joripspace secret update --project PROJECT --name API_KEY --value-stdin
|
|
@@ -81,12 +82,12 @@ Environment:
|
|
|
81
82
|
JORIPSPACE_CONNECT_TOKEN Used when no API token is provided
|
|
82
83
|
|
|
83
84
|
Login:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
Reuse existing valid logins; otherwise login creates a five-minute approval link.
|
|
86
|
+
Agents run login --no-open --json and show approval_url from stderr.
|
|
87
|
+
Keep the process running; stdout returns one final JSON result with next_action.
|
|
88
|
+
The user signs in and approves. No code entry is needed.
|
|
89
|
+
--no-open prevents launching a browser. Errors never trigger another authentication flow.
|
|
90
|
+
If authentication is missing, do not inspect cookies, browser storage or profile pages.
|
|
90
91
|
New logins store tokens in Windows Credential Manager, macOS Keychain, or Linux Secret Service.
|
|
91
92
|
Saved connections are reused in other project folders on the same OS user account.
|
|
92
93
|
New logins prefer the OS credential store. If unavailable before writing, the token is saved
|
|
@@ -119,7 +120,7 @@ Security:
|
|
|
119
120
|
Manage members, billing, token issuance, webhooks, and project deletion in the web UI.
|
|
120
121
|
tokens current returns the current token ID without its secret.
|
|
121
122
|
tokens revoke disables a token server-side within your account. --current ends this connection;
|
|
122
|
-
|
|
123
|
+
run login to reconnect by approval link. logout only removes local credentials.
|
|
123
124
|
|
|
124
125
|
${message('Language', '언어')}:
|
|
125
126
|
${message('Messages follow the OS default locale: Korean or English. Unsupported locales use English.', '안내는 OS 기본 로캘에 따라 한국어 또는 영어로 표시합니다. 미지원 로캘은 영어를 사용합니다.')}
|
|
@@ -133,17 +134,18 @@ Global flags:
|
|
|
133
134
|
`);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
function printReportHelp() {
|
|
137
|
-
|
|
137
|
+
function printReportHelp(command = 'report') {
|
|
138
|
+
const feedback = command === 'feedback';
|
|
139
|
+
console.log(`JoripSpace ${command}
|
|
138
140
|
|
|
139
141
|
Submit a project-related problem, bug, or improvement suggestion to JoripSpace.
|
|
140
142
|
|
|
141
143
|
Usage:
|
|
142
|
-
joripspace
|
|
144
|
+
joripspace ${command} --project PROJECT ${feedback ? '' : '--category problem|bug|feedback '}--summary "SUMMARY"
|
|
143
145
|
|
|
144
146
|
Options:
|
|
145
147
|
--project PROJECT Existing project name; defaults to the current linked project.
|
|
146
|
-
--category TYPE problem (default), bug, or feedback (suggestions and improvements).
|
|
148
|
+
${feedback ? ' Category is always feedback. This command wraps report --category feedback.' : ' --category TYPE problem (default), bug, or feedback (suggestions and improvements).'}
|
|
147
149
|
--summary TEXT Required summary, up to 160 characters. --message is an alias.
|
|
148
150
|
--details TEXT Context or reproduction steps, up to 8000 characters.
|
|
149
151
|
--expected TEXT Expected behavior or desired improvement, up to 4000 characters.
|
|
@@ -153,8 +155,8 @@ Options:
|
|
|
153
155
|
--json Return structured success or failure without prompting.
|
|
154
156
|
|
|
155
157
|
Examples:
|
|
156
|
-
joripspace
|
|
157
|
-
joripspace
|
|
158
|
+
joripspace ${command}${feedback ? '' : ' --category bug'} --summary "${feedback ? 'Add filtering to deployment history' : 'Deployment status is incorrect'}"
|
|
159
|
+
joripspace feedback --summary "Add filtering to deployment history"
|
|
158
160
|
|
|
159
161
|
The command sends a report; it does not just save a local draft.
|
|
160
162
|
Use an existing login. Never include credentials, personal data, or private source.
|
|
@@ -171,10 +173,16 @@ Usage:
|
|
|
171
173
|
|
|
172
174
|
Options:
|
|
173
175
|
--source PATH Deploy one source file. Entrypoint defaults to the file basename.
|
|
176
|
+
--prepare Validate built output and save a portable joripspace:deploy npm script; no deployment.
|
|
174
177
|
--dir PATH Deploy every safe file under a directory. Authentication is resolved from --cwd.
|
|
175
178
|
--file NAME=PATH Add one file mapping. Can be repeated.
|
|
176
179
|
--entrypoint NAME Server module entrypoint.
|
|
177
180
|
--label TEXT Required deployment label, up to 120 characters.
|
|
181
|
+
|
|
182
|
+
Prepare once after building (direct deployment only):
|
|
183
|
+
joripspace deploy --prepare --dir dist --entrypoint worker.js --json
|
|
184
|
+
Then, when deployment is requested:
|
|
185
|
+
npm run joripspace:deploy -- --label "Describe the change"
|
|
178
186
|
`);
|
|
179
187
|
}
|
|
180
188
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function createLoginCommand({ ensureProjectEnvIgnored, projectWorkspaceDir, stringFlag, normalizeCredentialApiUrl, unauthenticatedApiBaseUrl, normalizeConnectToken, saveBrowserConnectToken, resolveConnection, approvalLogin }) {
|
|
2
|
+
return async function login(flags) {
|
|
3
|
+
if (flags['connect-token'] !== undefined || flags.code !== undefined || flags['legacy-code'] !== undefined) {
|
|
4
|
+
throw Object.assign(new Error('Run login without code options to approve the connection in your browser.'), { code: 'unsupported_login_option' });
|
|
5
|
+
}
|
|
6
|
+
let existing;
|
|
7
|
+
try { existing = resolveConnection(flags); }
|
|
8
|
+
catch (error) { if (error.code !== 'credential_store_unavailable') throw error; }
|
|
9
|
+
if (existing?.apiToken) {
|
|
10
|
+
try {
|
|
11
|
+
await saveBrowserConnectToken(flags, normalizeConnectToken(existing.apiToken), existing.source, existing.apiBaseUrl);
|
|
12
|
+
return;
|
|
13
|
+
} catch (error) { if (error.status !== 401) throw error; }
|
|
14
|
+
}
|
|
15
|
+
ensureProjectEnvIgnored(projectWorkspaceDir(flags, { discover: false }));
|
|
16
|
+
await approvalLogin.login({ ...flags, 'no-open': flags['no-open'] || !!flags.json }, normalizeCredentialApiUrl(unauthenticatedApiBaseUrl(flags)));
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
module.exports = { createLoginCommand };
|
package/lib/project-create.js
CHANGED
|
@@ -140,7 +140,7 @@ function loginRequired(name) {
|
|
|
140
140
|
);
|
|
141
141
|
error.exitCode = 2;
|
|
142
142
|
error.details = {
|
|
143
|
-
|
|
143
|
+
connection_method: 'approval_link',
|
|
144
144
|
login_args: ['login', '--json'],
|
|
145
145
|
resume_args: ['create', '--name', name, '--json'],
|
|
146
146
|
next_action: 'login-then-retry-create; obtain-explicit-agreement-after-login',
|
package/lib/secret-commands.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { message } = require('./locale');
|
|
2
|
-
|
|
3
|
-
function secretManagementUrl(project) {
|
|
4
|
-
return `https://joripspace.com/projects/${encodeURIComponent(project)}/?tab=secrets`;
|
|
5
|
-
}
|
|
2
|
+
const { secretEntryName, secretManagementUrl, secretEntryHandoff } = require('../vendor/core/secret-entry.cjs');
|
|
6
3
|
|
|
7
4
|
function createSecretCommands(deps) {
|
|
8
5
|
return async function secrets(rest, flags) {
|
|
@@ -14,12 +11,15 @@ function createSecretCommands(deps) {
|
|
|
14
11
|
throw new Error('secret command requires: list, generate, set, or update');
|
|
15
12
|
}
|
|
16
13
|
const project = deps.requireProjectId(flags);
|
|
17
|
-
const
|
|
14
|
+
const requestedName = deps.stringFlag(flags, 'name');
|
|
15
|
+
if (requestedName && !secretEntryName(requestedName)) throw new Error('Invalid or reserved secret name.');
|
|
16
|
+
const url = secretManagementUrl(project, requestedName);
|
|
18
17
|
const auth = deps.projectAuth(flags);
|
|
19
18
|
const endpoint = `/v1/projects/${encodeURIComponent(project)}/secrets`;
|
|
20
19
|
let result;
|
|
21
20
|
if (subcommand === 'list') {
|
|
22
21
|
result = await deps.apiRequest(flags, endpoint, { method: 'GET', ...auth });
|
|
22
|
+
if (requestedName) result = { ...result, secret_entry: secretEntryHandoff(project, requestedName, result.secrets || []) };
|
|
23
23
|
} else {
|
|
24
24
|
const name = deps.stringFlag(flags, 'name').toUpperCase();
|
|
25
25
|
if (!name || !/^[_A-Z][_A-Z0-9]{0,127}$/.test(name)) {
|