@dura-run/cli 0.1.3 → 0.1.5
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/dist/dura.js +77 -32
- package/package.json +1 -1
package/dist/dura.js
CHANGED
|
@@ -2447,10 +2447,19 @@ function registerLoginCommand(program2) {
|
|
|
2447
2447
|
output.info("Opening browser for login...");
|
|
2448
2448
|
output.info(`If the browser doesn't open, visit: ${loginUrl}`);
|
|
2449
2449
|
await openBrowser(loginUrl);
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2450
|
+
let timeoutHandle;
|
|
2451
|
+
let authCode;
|
|
2452
|
+
try {
|
|
2453
|
+
authCode = await Promise.race([
|
|
2454
|
+
callbackResult.codePromise,
|
|
2455
|
+
new Promise((_, reject) => {
|
|
2456
|
+
timeoutHandle = setTimeout(() => reject(new Error("Login timed out after 120 seconds")), 120000);
|
|
2457
|
+
})
|
|
2458
|
+
]);
|
|
2459
|
+
} finally {
|
|
2460
|
+
if (timeoutHandle)
|
|
2461
|
+
clearTimeout(timeoutHandle);
|
|
2462
|
+
}
|
|
2454
2463
|
const exchangeRes = await fetch(`${apiUrl}/api/v1/cli-auth/exchange`, {
|
|
2455
2464
|
method: "POST",
|
|
2456
2465
|
headers: { "Content-Type": "application/json" },
|
|
@@ -2461,8 +2470,11 @@ function registerLoginCommand(program2) {
|
|
|
2461
2470
|
throw new Error(errBody.message ?? "Failed to exchange authorization code");
|
|
2462
2471
|
}
|
|
2463
2472
|
const exchangeData = await exchangeRes.json();
|
|
2464
|
-
const { key, email } = exchangeData.data;
|
|
2465
|
-
const updates = {
|
|
2473
|
+
const { key, email, orgId } = exchangeData.data;
|
|
2474
|
+
const updates = {
|
|
2475
|
+
apiKey: key,
|
|
2476
|
+
defaultOrgId: orgId
|
|
2477
|
+
};
|
|
2466
2478
|
if (opts.apiUrl) {
|
|
2467
2479
|
updates["apiUrl"] = opts.apiUrl;
|
|
2468
2480
|
}
|
|
@@ -2473,6 +2485,7 @@ function registerLoginCommand(program2) {
|
|
|
2473
2485
|
output.error("LOGIN_FAILED", err instanceof Error ? err.message : "Login failed", "Try again or use --api-key <key> to authenticate with an API key");
|
|
2474
2486
|
} finally {
|
|
2475
2487
|
if (server) {
|
|
2488
|
+
server.closeAllConnections?.();
|
|
2476
2489
|
server.close();
|
|
2477
2490
|
}
|
|
2478
2491
|
}
|
|
@@ -2526,6 +2539,9 @@ class ApiClient {
|
|
|
2526
2539
|
const contentType = response.headers.get("content-type");
|
|
2527
2540
|
if (!contentType?.includes("application/json")) {
|
|
2528
2541
|
const preview = await response.text().then((t) => t.slice(0, 200));
|
|
2542
|
+
if (response.status === 404) {
|
|
2543
|
+
throw new ApiClientError("ROUTE_NOT_FOUND", "Route not found on the server. The endpoint may not be available in this control plane deployment.", 404, "Upgrade the CLI (npm i -g @dura-run/cli@latest) or verify the control plane version supports this command.");
|
|
2544
|
+
}
|
|
2529
2545
|
throw new ApiClientError("UNEXPECTED_RESPONSE", `Expected JSON from server but got ${contentType ?? "unknown content-type"} (HTTP ${response.status}): ${preview}`, response.status, "Check that DURA_API_URL points to a valid dura.run API server");
|
|
2530
2546
|
}
|
|
2531
2547
|
const body = await response.json();
|
|
@@ -14086,7 +14102,7 @@ function registerOpenApiCommand(program2) {
|
|
|
14086
14102
|
const apiUrl = opts.apiUrl || getApiUrl();
|
|
14087
14103
|
const client = new ApiClient(apiUrl, token);
|
|
14088
14104
|
try {
|
|
14089
|
-
const spec = await client.get(
|
|
14105
|
+
const spec = await client.get(`/api/v1/projects/${opts.project}/openapi/_dura/openapi.json`, { projectId: opts.project });
|
|
14090
14106
|
output.success(spec);
|
|
14091
14107
|
} catch (err) {
|
|
14092
14108
|
if (err instanceof Error) {
|
|
@@ -16881,8 +16897,12 @@ function registerKvCommand(program2) {
|
|
|
16881
16897
|
}
|
|
16882
16898
|
}
|
|
16883
16899
|
});
|
|
16884
|
-
kv.command("delete <key>").description("Delete a key from the KV namespace").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (key, opts, cmd) => {
|
|
16900
|
+
kv.command("delete <key>").description("Delete a key from the KV namespace").requiredOption("--project <id>", "Project ID").option("--confirm", "Required to actually perform the delete").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (key, opts, cmd) => {
|
|
16885
16901
|
const output = getOutput(cmd);
|
|
16902
|
+
if (!opts.confirm) {
|
|
16903
|
+
output.error("KV_DELETE_CONFIRM_REQUIRED", `This will permanently delete the key "${key}".`, "Re-run with --confirm to proceed.");
|
|
16904
|
+
return;
|
|
16905
|
+
}
|
|
16886
16906
|
const auth = resolveAuth4(opts, output);
|
|
16887
16907
|
if (!auth)
|
|
16888
16908
|
return;
|
|
@@ -19017,6 +19037,31 @@ __export(exports_projects, {
|
|
|
19017
19037
|
});
|
|
19018
19038
|
function registerProjectsCommand(program2) {
|
|
19019
19039
|
const projects2 = program2.command("projects").description("Manage projects");
|
|
19040
|
+
projects2.command("get <projectId>").description("Show details for a single project").option("--org <id>", "Organization ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (projectId, opts, cmd) => {
|
|
19041
|
+
const output = getOutput(cmd);
|
|
19042
|
+
const token = opts.token || getAuthToken();
|
|
19043
|
+
if (!token) {
|
|
19044
|
+
output.error("AUTH_REQUIRED", "Not logged in", "Run: dura login");
|
|
19045
|
+
return;
|
|
19046
|
+
}
|
|
19047
|
+
const orgId = opts.org || readConfig().defaultOrgId;
|
|
19048
|
+
if (!orgId) {
|
|
19049
|
+
output.error("ORG_REQUIRED", "Organization ID is required", "Pass --org <id> or set a default org with dura login");
|
|
19050
|
+
return;
|
|
19051
|
+
}
|
|
19052
|
+
const apiUrl = opts.apiUrl || getApiUrl();
|
|
19053
|
+
const client = new ApiClient(apiUrl, token);
|
|
19054
|
+
try {
|
|
19055
|
+
const project = await client.get(`/api/v1/orgs/${orgId}/projects/${projectId}`);
|
|
19056
|
+
output.success(project);
|
|
19057
|
+
} catch (err) {
|
|
19058
|
+
if (err instanceof ApiClientError) {
|
|
19059
|
+
output.error(err.code, err.message, err.suggestion);
|
|
19060
|
+
} else if (err instanceof Error) {
|
|
19061
|
+
output.error("PROJECTS_GET_FAILED", err.message);
|
|
19062
|
+
}
|
|
19063
|
+
}
|
|
19064
|
+
});
|
|
19020
19065
|
projects2.command("list").description("List all projects in the organization").option("--org <id>", "Organization ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
19021
19066
|
const output = getOutput(cmd);
|
|
19022
19067
|
const token = opts.token || getAuthToken();
|
|
@@ -19125,48 +19170,48 @@ async function registerAllCommands(program2) {
|
|
|
19125
19170
|
const { registerProjectsCommand: registerProjectsCommand2 } = await Promise.resolve().then(() => (init_projects2(), exports_projects));
|
|
19126
19171
|
registerLoginCommand2(program2);
|
|
19127
19172
|
registerLogoutCommand2(program2);
|
|
19173
|
+
registerConfigCommand2(program2);
|
|
19128
19174
|
registerNewCommand2(program2);
|
|
19129
19175
|
registerInitCommand2(program2);
|
|
19176
|
+
registerCreateCommand2(program2);
|
|
19177
|
+
registerAddCommand2(program2);
|
|
19178
|
+
registerProjectsCommand2(program2);
|
|
19179
|
+
registerTemplateCommand2(program2);
|
|
19130
19180
|
registerSecretsCommand2(program2);
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19181
|
+
registerDomainsCommand2(program2);
|
|
19182
|
+
registerEndpointKeysCommand2(program2);
|
|
19183
|
+
registerEnvCommand2(program2);
|
|
19134
19184
|
registerDeployCommand2(program2);
|
|
19135
19185
|
registerRollbackCommand2(program2);
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
registerScheduleCommand2(program2);
|
|
19186
|
+
registerDeploymentsCommand2(program2);
|
|
19187
|
+
registerPromoteCommand2(program2);
|
|
19188
|
+
registerCanaryCommand2(program2);
|
|
19140
19189
|
registerDevCommand2(program2);
|
|
19141
19190
|
registerTestCommand2(program2);
|
|
19142
|
-
|
|
19143
|
-
|
|
19191
|
+
registerRunCommand2(program2);
|
|
19192
|
+
registerScheduleCommand2(program2);
|
|
19193
|
+
registerStatusCommand2(program2);
|
|
19194
|
+
registerLogsCommand2(program2);
|
|
19144
19195
|
registerUsageCommand2(program2);
|
|
19145
|
-
|
|
19146
|
-
registerExportCommand2(program2);
|
|
19196
|
+
registerAuditCommand2(program2);
|
|
19147
19197
|
registerReplayCommand2(program2);
|
|
19148
19198
|
registerReplaysCommand2(program2);
|
|
19149
|
-
registerKvCommand2(program2);
|
|
19150
|
-
registerWebhookCommand2(program2);
|
|
19151
|
-
registerTemplateCommand2(program2);
|
|
19152
|
-
registerDeploymentsCommand2(program2);
|
|
19153
19199
|
registerDiagnoseCommand2(program2);
|
|
19154
|
-
registerCreateCommand2(program2);
|
|
19155
|
-
registerAddCommand2(program2);
|
|
19156
19200
|
registerWorkflowsCommand2(program2);
|
|
19157
19201
|
registerWorkflowCommand2(program2);
|
|
19158
19202
|
registerApprovalsCommand2(program2);
|
|
19159
19203
|
registerApproveCommand2(program2);
|
|
19160
19204
|
registerRejectCommand2(program2);
|
|
19161
|
-
registerEnvCommand2(program2);
|
|
19162
|
-
registerPromoteCommand2(program2);
|
|
19163
|
-
registerCanaryCommand2(program2);
|
|
19164
|
-
registerReportsCommand2(program2);
|
|
19165
19205
|
registerHealCommand2(program2);
|
|
19166
|
-
|
|
19206
|
+
registerReportsCommand2(program2);
|
|
19207
|
+
registerWebhookCommand2(program2);
|
|
19208
|
+
registerMarketplaceCommand2(program2);
|
|
19209
|
+
registerKvCommand2(program2);
|
|
19210
|
+
registerExportCommand2(program2);
|
|
19211
|
+
registerOpenApiCommand2(program2);
|
|
19167
19212
|
return program2;
|
|
19168
19213
|
}
|
|
19169
|
-
var CLI_VERSION = "0.1.
|
|
19214
|
+
var CLI_VERSION = "0.1.5";
|
|
19170
19215
|
var init_src3 = __esm(() => {
|
|
19171
19216
|
init_esm();
|
|
19172
19217
|
if (import.meta.url === `file://${realpathSync(process.argv[1] ?? "").replace(/\\/g, "/")}`) {
|
|
@@ -19183,4 +19228,4 @@ export {
|
|
|
19183
19228
|
CLI_VERSION
|
|
19184
19229
|
};
|
|
19185
19230
|
|
|
19186
|
-
//# debugId=
|
|
19231
|
+
//# debugId=CD666733E632C5CB64756E2164756E21
|