@dura-run/cli 0.3.0 → 0.3.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.
- package/dist/dura.js +209 -364
- package/package.json +1 -1
package/dist/dura.js
CHANGED
|
@@ -2834,6 +2834,22 @@ var init_hello = __esm(() => {
|
|
|
2834
2834
|
HELLO_TEMPLATE = GET_TEMPLATE;
|
|
2835
2835
|
});
|
|
2836
2836
|
|
|
2837
|
+
// src/lib/handle-api-error.ts
|
|
2838
|
+
function reportApiError(output, err, fallbackCode) {
|
|
2839
|
+
if (err instanceof ApiClientError) {
|
|
2840
|
+
output.error(err.code, err.message, err.suggestion);
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
if (err instanceof Error) {
|
|
2844
|
+
output.error(fallbackCode, err.message);
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
output.error(fallbackCode, String(err));
|
|
2848
|
+
}
|
|
2849
|
+
var init_handle_api_error = __esm(() => {
|
|
2850
|
+
init_api_client();
|
|
2851
|
+
});
|
|
2852
|
+
|
|
2837
2853
|
// src/commands/new.ts
|
|
2838
2854
|
var exports_new = {};
|
|
2839
2855
|
__export(exports_new, {
|
|
@@ -2890,11 +2906,7 @@ function registerNewCommand(program2) {
|
|
|
2890
2906
|
Set required secrets: ${result.requiredSecrets.join(", ")}`);
|
|
2891
2907
|
}
|
|
2892
2908
|
} catch (err) {
|
|
2893
|
-
|
|
2894
|
-
output.error(err.code, err.message, err.suggestion);
|
|
2895
|
-
} else if (err instanceof Error) {
|
|
2896
|
-
output.error("FORK_FAILED", err.message);
|
|
2897
|
-
}
|
|
2909
|
+
reportApiError(output, err, "FORK_FAILED");
|
|
2898
2910
|
}
|
|
2899
2911
|
return;
|
|
2900
2912
|
}
|
|
@@ -2948,6 +2960,7 @@ var init_new = __esm(() => {
|
|
|
2948
2960
|
init_hello();
|
|
2949
2961
|
init_api_client();
|
|
2950
2962
|
init_config_store();
|
|
2963
|
+
init_handle_api_error();
|
|
2951
2964
|
});
|
|
2952
2965
|
|
|
2953
2966
|
// src/lib/project-id.ts
|
|
@@ -3002,9 +3015,7 @@ function registerSecretsCommand(program2) {
|
|
|
3002
3015
|
const result = await client.put(`/api/v1/projects/${projectId}/secrets`, { name, value });
|
|
3003
3016
|
output.success(result);
|
|
3004
3017
|
} catch (err) {
|
|
3005
|
-
|
|
3006
|
-
output.error("SECRET_SET_FAILED", err.message);
|
|
3007
|
-
}
|
|
3018
|
+
reportApiError(output, err, "SECRET_SET_FAILED");
|
|
3008
3019
|
}
|
|
3009
3020
|
});
|
|
3010
3021
|
secrets.command("list").description("List secret names (values never shown)").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -3017,9 +3028,7 @@ function registerSecretsCommand(program2) {
|
|
|
3017
3028
|
const result = await client.get(`/api/v1/projects/${projectId}/secrets`);
|
|
3018
3029
|
output.table(["Name", "Created", "Updated"], result.map((s) => [s.name, s.createdAt, s.updatedAt]));
|
|
3019
3030
|
} catch (err) {
|
|
3020
|
-
|
|
3021
|
-
output.error("SECRET_LIST_FAILED", err.message);
|
|
3022
|
-
}
|
|
3031
|
+
reportApiError(output, err, "SECRET_LIST_FAILED");
|
|
3023
3032
|
}
|
|
3024
3033
|
});
|
|
3025
3034
|
secrets.command("remove <name>").description("Remove a secret").option("--project <id>", "Project ID (defaults to dura.json)").option("--confirm", "Confirm this destructive operation").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (name, opts, cmd) => {
|
|
@@ -3036,9 +3045,7 @@ function registerSecretsCommand(program2) {
|
|
|
3036
3045
|
await client.delete(`/api/v1/projects/${projectId}/secrets/${name}`);
|
|
3037
3046
|
output.success({ deleted: true, name });
|
|
3038
3047
|
} catch (err) {
|
|
3039
|
-
|
|
3040
|
-
output.error("SECRET_REMOVE_FAILED", err.message);
|
|
3041
|
-
}
|
|
3048
|
+
reportApiError(output, err, "SECRET_REMOVE_FAILED");
|
|
3042
3049
|
}
|
|
3043
3050
|
});
|
|
3044
3051
|
secrets.command("pull").description("Write secrets to .env.local for local development").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").option("--dir <path>", "Directory to write .env.local to", ".").action(async (opts, cmd) => {
|
|
@@ -3059,9 +3066,7 @@ function registerSecretsCommand(program2) {
|
|
|
3059
3066
|
count: Object.keys(values).length
|
|
3060
3067
|
});
|
|
3061
3068
|
} catch (err) {
|
|
3062
|
-
|
|
3063
|
-
output.error("SECRET_PULL_FAILED", err.message);
|
|
3064
|
-
}
|
|
3069
|
+
reportApiError(output, err, "SECRET_PULL_FAILED");
|
|
3065
3070
|
}
|
|
3066
3071
|
});
|
|
3067
3072
|
}
|
|
@@ -3069,6 +3074,7 @@ var init_secrets = __esm(() => {
|
|
|
3069
3074
|
init_src3();
|
|
3070
3075
|
init_api_client();
|
|
3071
3076
|
init_config_store();
|
|
3077
|
+
init_handle_api_error();
|
|
3072
3078
|
init_project_id();
|
|
3073
3079
|
});
|
|
3074
3080
|
|
|
@@ -13884,9 +13890,7 @@ function registerConfigCommand(program2) {
|
|
|
13884
13890
|
setManifestValue(opts.dir, path, parsed);
|
|
13885
13891
|
output.success({ path, value: parsed });
|
|
13886
13892
|
} catch (err) {
|
|
13887
|
-
|
|
13888
|
-
output.error("CONFIG_SET_FAILED", err.message);
|
|
13889
|
-
}
|
|
13893
|
+
reportApiError(output, err, "CONFIG_SET_FAILED");
|
|
13890
13894
|
}
|
|
13891
13895
|
});
|
|
13892
13896
|
config.command("get <path>").description("Get a config value using dot-path notation").option("--dir <path>", "Project directory", ".").action((path, opts, cmd) => {
|
|
@@ -13899,15 +13903,14 @@ function registerConfigCommand(program2) {
|
|
|
13899
13903
|
}
|
|
13900
13904
|
output.success({ path, value });
|
|
13901
13905
|
} catch (err) {
|
|
13902
|
-
|
|
13903
|
-
output.error("CONFIG_GET_FAILED", err.message);
|
|
13904
|
-
}
|
|
13906
|
+
reportApiError(output, err, "CONFIG_GET_FAILED");
|
|
13905
13907
|
}
|
|
13906
13908
|
});
|
|
13907
13909
|
}
|
|
13908
13910
|
var init_config = __esm(() => {
|
|
13909
13911
|
init_src3();
|
|
13910
13912
|
init_manifest2();
|
|
13913
|
+
init_handle_api_error();
|
|
13911
13914
|
});
|
|
13912
13915
|
|
|
13913
13916
|
// src/commands/status.ts
|
|
@@ -13929,9 +13932,7 @@ function registerStatusCommand(program2) {
|
|
|
13929
13932
|
const project = await client.get(`/api/v1/orgs/${opts.org}/projects/${opts.project}`);
|
|
13930
13933
|
output.success(project);
|
|
13931
13934
|
} catch (err) {
|
|
13932
|
-
|
|
13933
|
-
output.error("STATUS_FAILED", err.message);
|
|
13934
|
-
}
|
|
13935
|
+
reportApiError(output, err, "STATUS_FAILED");
|
|
13935
13936
|
}
|
|
13936
13937
|
});
|
|
13937
13938
|
}
|
|
@@ -13939,6 +13940,7 @@ var init_status = __esm(() => {
|
|
|
13939
13940
|
init_src3();
|
|
13940
13941
|
init_api_client();
|
|
13941
13942
|
init_config_store();
|
|
13943
|
+
init_handle_api_error();
|
|
13942
13944
|
});
|
|
13943
13945
|
|
|
13944
13946
|
// src/commands/audit.ts
|
|
@@ -13970,9 +13972,7 @@ function registerAuditCommand(program2) {
|
|
|
13970
13972
|
e.userId
|
|
13971
13973
|
]));
|
|
13972
13974
|
} catch (err) {
|
|
13973
|
-
|
|
13974
|
-
output.error("AUDIT_FAILED", err.message);
|
|
13975
|
-
}
|
|
13975
|
+
reportApiError(output, err, "AUDIT_FAILED");
|
|
13976
13976
|
}
|
|
13977
13977
|
});
|
|
13978
13978
|
}
|
|
@@ -13980,6 +13980,7 @@ var init_audit = __esm(() => {
|
|
|
13980
13980
|
init_src3();
|
|
13981
13981
|
init_api_client();
|
|
13982
13982
|
init_config_store();
|
|
13983
|
+
init_handle_api_error();
|
|
13983
13984
|
});
|
|
13984
13985
|
|
|
13985
13986
|
// src/lib/manifest-generator.ts
|
|
@@ -14230,11 +14231,7 @@ Live at:`);
|
|
|
14230
14231
|
}
|
|
14231
14232
|
}
|
|
14232
14233
|
} catch (err) {
|
|
14233
|
-
|
|
14234
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14235
|
-
} else if (err instanceof Error) {
|
|
14236
|
-
output.error("DEPLOY_FAILED", err.message);
|
|
14237
|
-
}
|
|
14234
|
+
reportApiError(output, err, "DEPLOY_FAILED");
|
|
14238
14235
|
}
|
|
14239
14236
|
});
|
|
14240
14237
|
}
|
|
@@ -14244,6 +14241,7 @@ var init_deploy = __esm(() => {
|
|
|
14244
14241
|
init_config_store();
|
|
14245
14242
|
init_bundler();
|
|
14246
14243
|
init_manifest2();
|
|
14244
|
+
init_handle_api_error();
|
|
14247
14245
|
});
|
|
14248
14246
|
|
|
14249
14247
|
// src/commands/rollback.ts
|
|
@@ -14273,11 +14271,7 @@ function registerRollbackCommand(program2) {
|
|
|
14273
14271
|
activatedAt: deployment.activatedAt
|
|
14274
14272
|
});
|
|
14275
14273
|
} catch (err) {
|
|
14276
|
-
|
|
14277
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14278
|
-
} else if (err instanceof Error) {
|
|
14279
|
-
output.error("ROLLBACK_FAILED", err.message);
|
|
14280
|
-
}
|
|
14274
|
+
reportApiError(output, err, "ROLLBACK_FAILED");
|
|
14281
14275
|
}
|
|
14282
14276
|
});
|
|
14283
14277
|
}
|
|
@@ -14285,6 +14279,7 @@ var init_rollback = __esm(() => {
|
|
|
14285
14279
|
init_src3();
|
|
14286
14280
|
init_api_client();
|
|
14287
14281
|
init_config_store();
|
|
14282
|
+
init_handle_api_error();
|
|
14288
14283
|
});
|
|
14289
14284
|
|
|
14290
14285
|
// src/commands/openapi.ts
|
|
@@ -14306,9 +14301,7 @@ function registerOpenApiCommand(program2) {
|
|
|
14306
14301
|
const spec = await client.get(`/api/v1/projects/${opts.project}/openapi/_dura/openapi.json`, { projectId: opts.project });
|
|
14307
14302
|
output.success(spec);
|
|
14308
14303
|
} catch (err) {
|
|
14309
|
-
|
|
14310
|
-
output.error("OPENAPI_FAILED", err.message);
|
|
14311
|
-
}
|
|
14304
|
+
reportApiError(output, err, "OPENAPI_FAILED");
|
|
14312
14305
|
}
|
|
14313
14306
|
});
|
|
14314
14307
|
}
|
|
@@ -14316,6 +14309,7 @@ var init_openapi = __esm(() => {
|
|
|
14316
14309
|
init_src3();
|
|
14317
14310
|
init_api_client();
|
|
14318
14311
|
init_config_store();
|
|
14312
|
+
init_handle_api_error();
|
|
14319
14313
|
});
|
|
14320
14314
|
|
|
14321
14315
|
// src/commands/logs.ts
|
|
@@ -14579,11 +14573,7 @@ Error: ${name}
|
|
|
14579
14573
|
]));
|
|
14580
14574
|
}
|
|
14581
14575
|
} catch (err) {
|
|
14582
|
-
|
|
14583
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14584
|
-
} else if (err instanceof Error) {
|
|
14585
|
-
output.error("LOGS_FAILED", err.message);
|
|
14586
|
-
}
|
|
14576
|
+
reportApiError(output, err, "LOGS_FAILED");
|
|
14587
14577
|
}
|
|
14588
14578
|
});
|
|
14589
14579
|
}
|
|
@@ -14592,6 +14582,7 @@ var init_logs = __esm(() => {
|
|
|
14592
14582
|
init_api_client();
|
|
14593
14583
|
init_config_store();
|
|
14594
14584
|
init_project_id();
|
|
14585
|
+
init_handle_api_error();
|
|
14595
14586
|
});
|
|
14596
14587
|
|
|
14597
14588
|
// src/commands/run.ts
|
|
@@ -14625,11 +14616,7 @@ function registerRunCommand(program2) {
|
|
|
14625
14616
|
});
|
|
14626
14617
|
output.success(result);
|
|
14627
14618
|
} catch (err) {
|
|
14628
|
-
|
|
14629
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14630
|
-
} else if (err instanceof Error) {
|
|
14631
|
-
output.error("RUN_FAILED", err.message);
|
|
14632
|
-
}
|
|
14619
|
+
reportApiError(output, err, "RUN_FAILED");
|
|
14633
14620
|
}
|
|
14634
14621
|
});
|
|
14635
14622
|
}
|
|
@@ -14637,6 +14624,7 @@ var init_run = __esm(() => {
|
|
|
14637
14624
|
init_src3();
|
|
14638
14625
|
init_api_client();
|
|
14639
14626
|
init_config_store();
|
|
14627
|
+
init_handle_api_error();
|
|
14640
14628
|
});
|
|
14641
14629
|
|
|
14642
14630
|
// src/commands/schedule.ts
|
|
@@ -14672,11 +14660,7 @@ function registerScheduleCommand(program2) {
|
|
|
14672
14660
|
});
|
|
14673
14661
|
output.success(result);
|
|
14674
14662
|
} catch (err) {
|
|
14675
|
-
|
|
14676
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14677
|
-
} else if (err instanceof Error) {
|
|
14678
|
-
output.error("SCHEDULE_FAILED", err.message);
|
|
14679
|
-
}
|
|
14663
|
+
reportApiError(output, err, "SCHEDULE_FAILED");
|
|
14680
14664
|
}
|
|
14681
14665
|
});
|
|
14682
14666
|
schedule.command("list").description("List cron schedules for a project").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -14695,11 +14679,7 @@ function registerScheduleCommand(program2) {
|
|
|
14695
14679
|
const result = await auth.client.get(`/api/v1/projects/${projectId}/schedules`);
|
|
14696
14680
|
output.success(result);
|
|
14697
14681
|
} catch (err) {
|
|
14698
|
-
|
|
14699
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14700
|
-
} else if (err instanceof Error) {
|
|
14701
|
-
output.error("SCHEDULE_LIST_FAILED", err.message);
|
|
14702
|
-
}
|
|
14682
|
+
reportApiError(output, err, "SCHEDULE_LIST_FAILED");
|
|
14703
14683
|
}
|
|
14704
14684
|
});
|
|
14705
14685
|
schedule.command("remove <schedule-id>").description("Remove a cron schedule").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").option("--confirm", "Confirm the destructive delete operation").action(async (scheduleId, opts, cmd) => {
|
|
@@ -14722,11 +14702,7 @@ function registerScheduleCommand(program2) {
|
|
|
14722
14702
|
const result = await auth.client.delete(`/api/v1/projects/${projectId}/schedules/${scheduleId}`);
|
|
14723
14703
|
output.success(result);
|
|
14724
14704
|
} catch (err) {
|
|
14725
|
-
|
|
14726
|
-
output.error(err.code, err.message, err.suggestion);
|
|
14727
|
-
} else if (err instanceof Error) {
|
|
14728
|
-
output.error("SCHEDULE_REMOVE_FAILED", err.message);
|
|
14729
|
-
}
|
|
14705
|
+
reportApiError(output, err, "SCHEDULE_REMOVE_FAILED");
|
|
14730
14706
|
}
|
|
14731
14707
|
});
|
|
14732
14708
|
}
|
|
@@ -14735,6 +14711,7 @@ var init_schedule = __esm(() => {
|
|
|
14735
14711
|
init_api_client();
|
|
14736
14712
|
init_config_store();
|
|
14737
14713
|
init_project_id();
|
|
14714
|
+
init_handle_api_error();
|
|
14738
14715
|
});
|
|
14739
14716
|
|
|
14740
14717
|
// src/lib/dev-trust.ts
|
|
@@ -16582,9 +16559,7 @@ Add this TXT record to your DNS:
|
|
|
16582
16559
|
Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
16583
16560
|
}
|
|
16584
16561
|
} catch (err) {
|
|
16585
|
-
|
|
16586
|
-
output.error("DOMAIN_ADD_FAILED", err.message);
|
|
16587
|
-
}
|
|
16562
|
+
reportApiError(output, err, "DOMAIN_ADD_FAILED");
|
|
16588
16563
|
}
|
|
16589
16564
|
});
|
|
16590
16565
|
domains.command("list").description("List custom domains").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -16602,9 +16577,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16602
16577
|
d.createdAt
|
|
16603
16578
|
]));
|
|
16604
16579
|
} catch (err) {
|
|
16605
|
-
|
|
16606
|
-
output.error("DOMAIN_LIST_FAILED", err.message);
|
|
16607
|
-
}
|
|
16580
|
+
reportApiError(output, err, "DOMAIN_LIST_FAILED");
|
|
16608
16581
|
}
|
|
16609
16582
|
});
|
|
16610
16583
|
domains.command("remove <domainId>").description("Remove a custom domain").option("--project <id>", "Project ID (defaults to dura.json)").option("--confirm", "Confirm this destructive operation").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (domainId, opts, cmd) => {
|
|
@@ -16621,9 +16594,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16621
16594
|
await client.delete(`/api/v1/projects/${projectId}/domains/${domainId}`);
|
|
16622
16595
|
output.success({ deleted: true, domainId });
|
|
16623
16596
|
} catch (err) {
|
|
16624
|
-
|
|
16625
|
-
output.error("DOMAIN_REMOVE_FAILED", err.message);
|
|
16626
|
-
}
|
|
16597
|
+
reportApiError(output, err, "DOMAIN_REMOVE_FAILED");
|
|
16627
16598
|
}
|
|
16628
16599
|
});
|
|
16629
16600
|
domains.command("verify <domainId>").description("Verify a domain's DNS TXT record").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (domainId, opts, cmd) => {
|
|
@@ -16636,9 +16607,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16636
16607
|
const result = await client.post(`/api/v1/projects/${projectId}/domains/${domainId}/verify`, {});
|
|
16637
16608
|
output.success(result);
|
|
16638
16609
|
} catch (err) {
|
|
16639
|
-
|
|
16640
|
-
output.error("DOMAIN_VERIFY_FAILED", err.message);
|
|
16641
|
-
}
|
|
16610
|
+
reportApiError(output, err, "DOMAIN_VERIFY_FAILED");
|
|
16642
16611
|
}
|
|
16643
16612
|
});
|
|
16644
16613
|
}
|
|
@@ -16647,6 +16616,7 @@ var init_domains = __esm(() => {
|
|
|
16647
16616
|
init_api_client();
|
|
16648
16617
|
init_config_store();
|
|
16649
16618
|
init_project_id();
|
|
16619
|
+
init_handle_api_error();
|
|
16650
16620
|
});
|
|
16651
16621
|
|
|
16652
16622
|
// src/commands/endpoint-keys.ts
|
|
@@ -16686,9 +16656,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16686
16656
|
output.warn("Save the key now — it will not be shown again.");
|
|
16687
16657
|
}
|
|
16688
16658
|
} catch (err) {
|
|
16689
|
-
|
|
16690
|
-
output.error("ENDPOINT_KEY_CREATE_FAILED", err.message);
|
|
16691
|
-
}
|
|
16659
|
+
reportApiError(output, err, "ENDPOINT_KEY_CREATE_FAILED");
|
|
16692
16660
|
}
|
|
16693
16661
|
});
|
|
16694
16662
|
keys.command("list").description("List endpoint keys for a project").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -16708,9 +16676,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16708
16676
|
k.createdAt
|
|
16709
16677
|
]));
|
|
16710
16678
|
} catch (err) {
|
|
16711
|
-
|
|
16712
|
-
output.error("ENDPOINT_KEY_LIST_FAILED", err.message);
|
|
16713
|
-
}
|
|
16679
|
+
reportApiError(output, err, "ENDPOINT_KEY_LIST_FAILED");
|
|
16714
16680
|
}
|
|
16715
16681
|
});
|
|
16716
16682
|
keys.command("revoke <keyId>").description("Revoke an endpoint key").option("--project <id>", "Project ID (defaults to dura.json)").option("--confirm", "Confirm this destructive operation").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (keyId, opts, cmd) => {
|
|
@@ -16727,9 +16693,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16727
16693
|
await client.post(`/api/v1/projects/${projectId}/endpoint-keys/${keyId}/revoke`, {});
|
|
16728
16694
|
output.success({ revoked: true, keyId });
|
|
16729
16695
|
} catch (err) {
|
|
16730
|
-
|
|
16731
|
-
output.error("ENDPOINT_KEY_REVOKE_FAILED", err.message);
|
|
16732
|
-
}
|
|
16696
|
+
reportApiError(output, err, "ENDPOINT_KEY_REVOKE_FAILED");
|
|
16733
16697
|
}
|
|
16734
16698
|
});
|
|
16735
16699
|
}
|
|
@@ -16738,6 +16702,81 @@ var init_endpoint_keys2 = __esm(() => {
|
|
|
16738
16702
|
init_api_client();
|
|
16739
16703
|
init_config_store();
|
|
16740
16704
|
init_project_id();
|
|
16705
|
+
init_handle_api_error();
|
|
16706
|
+
});
|
|
16707
|
+
|
|
16708
|
+
// src/commands/events.ts
|
|
16709
|
+
var exports_events = {};
|
|
16710
|
+
__export(exports_events, {
|
|
16711
|
+
resolvePayload: () => resolvePayload,
|
|
16712
|
+
registerEventsCommand: () => registerEventsCommand
|
|
16713
|
+
});
|
|
16714
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
16715
|
+
function resolvePayload(opts) {
|
|
16716
|
+
if (opts.payload !== undefined && opts.payloadFile !== undefined) {
|
|
16717
|
+
throw new Error("Use either --payload or --payload-file, not both");
|
|
16718
|
+
}
|
|
16719
|
+
if (opts.payload === undefined && opts.payloadFile === undefined) {
|
|
16720
|
+
throw new Error("--payload or --payload-file is required");
|
|
16721
|
+
}
|
|
16722
|
+
const raw = opts.payload !== undefined ? opts.payload : readFileSync8(opts.payloadFile, "utf-8");
|
|
16723
|
+
try {
|
|
16724
|
+
return JSON.parse(raw);
|
|
16725
|
+
} catch (err) {
|
|
16726
|
+
throw new Error(`Invalid JSON in payload: ${err.message}`);
|
|
16727
|
+
}
|
|
16728
|
+
}
|
|
16729
|
+
function registerEventsCommand(program2) {
|
|
16730
|
+
const events = program2.command("events").description("Emit and inspect project events");
|
|
16731
|
+
events.command("emit <source>").description("Emit an event to all matching event triggers").option("--payload <json>", "Inline JSON payload").option("--payload-file <path>", "Path to a JSON file containing the payload").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (source, opts, cmd) => {
|
|
16732
|
+
const output = getOutput(cmd);
|
|
16733
|
+
let payload;
|
|
16734
|
+
try {
|
|
16735
|
+
payload = resolvePayload(opts);
|
|
16736
|
+
} catch (err) {
|
|
16737
|
+
output.error("INVALID_PAYLOAD", err.message);
|
|
16738
|
+
return;
|
|
16739
|
+
}
|
|
16740
|
+
const projectId = resolveProjectId({ project: opts.project });
|
|
16741
|
+
if (!projectId) {
|
|
16742
|
+
output.error("PROJECT_REQUIRED", "No project ID. Use --project or run this command inside a dura.json project.");
|
|
16743
|
+
return;
|
|
16744
|
+
}
|
|
16745
|
+
const token = opts.token || getAuthToken();
|
|
16746
|
+
if (!token) {
|
|
16747
|
+
output.error("AUTH_REQUIRED", "Not logged in", "Run: dura login");
|
|
16748
|
+
return;
|
|
16749
|
+
}
|
|
16750
|
+
const apiUrl = opts.apiUrl || getApiUrl();
|
|
16751
|
+
const client = new ApiClient(apiUrl, token);
|
|
16752
|
+
try {
|
|
16753
|
+
const result = await client.post(`/api/v1/projects/${projectId}/events`, { source, payload });
|
|
16754
|
+
if (output.isJson()) {
|
|
16755
|
+
output.success(result);
|
|
16756
|
+
return;
|
|
16757
|
+
}
|
|
16758
|
+
if (result.jobs.length === 0) {
|
|
16759
|
+
process.stdout.write(`Event "${source}" emitted — no subscribers matched.
|
|
16760
|
+
`);
|
|
16761
|
+
return;
|
|
16762
|
+
}
|
|
16763
|
+
process.stdout.write(`Event "${source}" emitted — enqueued ${result.jobs.length} execution(s):
|
|
16764
|
+
`);
|
|
16765
|
+
for (const job of result.jobs) {
|
|
16766
|
+
process.stdout.write(` • ${job.automationName} → execution ${job.trigger.executionId}
|
|
16767
|
+
`);
|
|
16768
|
+
}
|
|
16769
|
+
} catch (err) {
|
|
16770
|
+
const e = err;
|
|
16771
|
+
output.error(e.code ?? "EMIT_FAILED", e.message);
|
|
16772
|
+
}
|
|
16773
|
+
});
|
|
16774
|
+
}
|
|
16775
|
+
var init_events = __esm(() => {
|
|
16776
|
+
init_src3();
|
|
16777
|
+
init_api_client();
|
|
16778
|
+
init_config_store();
|
|
16779
|
+
init_project_id();
|
|
16741
16780
|
});
|
|
16742
16781
|
|
|
16743
16782
|
// src/commands/usage.ts
|
|
@@ -16824,11 +16863,7 @@ function registerUsageCommand(program2) {
|
|
|
16824
16863
|
browserTime: formatMs(summary.totals.totalBrowserSessionMs)
|
|
16825
16864
|
});
|
|
16826
16865
|
} catch (err) {
|
|
16827
|
-
|
|
16828
|
-
output.error(err.code, err.message, err.suggestion);
|
|
16829
|
-
} else if (err instanceof Error) {
|
|
16830
|
-
output.error("USAGE_QUERY_FAILED", err.message);
|
|
16831
|
-
}
|
|
16866
|
+
reportApiError(output, err, "USAGE_QUERY_FAILED");
|
|
16832
16867
|
}
|
|
16833
16868
|
});
|
|
16834
16869
|
}
|
|
@@ -16836,6 +16871,7 @@ var init_usage = __esm(() => {
|
|
|
16836
16871
|
init_src3();
|
|
16837
16872
|
init_api_client();
|
|
16838
16873
|
init_config_store();
|
|
16874
|
+
init_handle_api_error();
|
|
16839
16875
|
});
|
|
16840
16876
|
|
|
16841
16877
|
// src/commands/marketplace.ts
|
|
@@ -16873,11 +16909,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16873
16909
|
status: adapter.status
|
|
16874
16910
|
});
|
|
16875
16911
|
} catch (err) {
|
|
16876
|
-
|
|
16877
|
-
output.error(err.code, err.message, err.suggestion);
|
|
16878
|
-
} else if (err instanceof Error) {
|
|
16879
|
-
output.error("PUBLISH_FAILED", err.message);
|
|
16880
|
-
}
|
|
16912
|
+
reportApiError(output, err, "PUBLISH_FAILED");
|
|
16881
16913
|
}
|
|
16882
16914
|
});
|
|
16883
16915
|
marketplace.command("install").description("Install an adapter into a project").requiredOption("--project <id>", "Project ID").requiredOption("--adapter <id>", "Adapter ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -16898,11 +16930,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16898
16930
|
version: install.adapterVersion
|
|
16899
16931
|
});
|
|
16900
16932
|
} catch (err) {
|
|
16901
|
-
|
|
16902
|
-
output.error(err.code, err.message, err.suggestion);
|
|
16903
|
-
} else if (err instanceof Error) {
|
|
16904
|
-
output.error("INSTALL_FAILED", err.message);
|
|
16905
|
-
}
|
|
16933
|
+
reportApiError(output, err, "INSTALL_FAILED");
|
|
16906
16934
|
}
|
|
16907
16935
|
});
|
|
16908
16936
|
marketplace.command("list").description("List available adapters").option("--category <cat>", "Filter by category").option("--query <q>", "Search query").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -16938,11 +16966,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16938
16966
|
a.status
|
|
16939
16967
|
]));
|
|
16940
16968
|
} catch (err) {
|
|
16941
|
-
|
|
16942
|
-
output.error(err.code, err.message, err.suggestion);
|
|
16943
|
-
} else if (err instanceof Error) {
|
|
16944
|
-
output.error("LIST_FAILED", err.message);
|
|
16945
|
-
}
|
|
16969
|
+
reportApiError(output, err, "LIST_FAILED");
|
|
16946
16970
|
}
|
|
16947
16971
|
});
|
|
16948
16972
|
marketplace.command("uninstall").description("Uninstall an adapter from a project").requiredOption("--project <id>", "Project ID").requiredOption("--adapter <id>", "Adapter ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").option("--confirm", "Confirm the destructive uninstall operation").action(async (opts, cmd) => {
|
|
@@ -16962,11 +16986,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16962
16986
|
await client.post(`/api/v1/projects/${opts.project}/adapters/uninstall`, { adapterId: opts.adapter });
|
|
16963
16987
|
output.success({ uninstalled: true, adapterId: opts.adapter });
|
|
16964
16988
|
} catch (err) {
|
|
16965
|
-
|
|
16966
|
-
output.error(err.code, err.message, err.suggestion);
|
|
16967
|
-
} else if (err instanceof Error) {
|
|
16968
|
-
output.error("UNINSTALL_FAILED", err.message);
|
|
16969
|
-
}
|
|
16989
|
+
reportApiError(output, err, "UNINSTALL_FAILED");
|
|
16970
16990
|
}
|
|
16971
16991
|
});
|
|
16972
16992
|
}
|
|
@@ -16974,6 +16994,7 @@ var init_marketplace2 = __esm(() => {
|
|
|
16974
16994
|
init_src3();
|
|
16975
16995
|
init_api_client();
|
|
16976
16996
|
init_config_store();
|
|
16997
|
+
init_handle_api_error();
|
|
16977
16998
|
});
|
|
16978
16999
|
|
|
16979
17000
|
// src/commands/export.ts
|
|
@@ -16985,7 +17006,7 @@ __export(exports_export, {
|
|
|
16985
17006
|
});
|
|
16986
17007
|
import {
|
|
16987
17008
|
existsSync as existsSync10,
|
|
16988
|
-
readFileSync as
|
|
17009
|
+
readFileSync as readFileSync9,
|
|
16989
17010
|
readdirSync as readdirSync3,
|
|
16990
17011
|
statSync,
|
|
16991
17012
|
writeFileSync as writeFileSync8
|
|
@@ -17005,7 +17026,7 @@ function collectExportFiles(baseDir, currentDir) {
|
|
|
17005
17026
|
}
|
|
17006
17027
|
} else if (stat.isFile()) {
|
|
17007
17028
|
if (!EXCLUDED_FILES.has(item)) {
|
|
17008
|
-
const content =
|
|
17029
|
+
const content = readFileSync9(fullPath, "utf-8");
|
|
17009
17030
|
entries.push({ relativePath: relPath, content });
|
|
17010
17031
|
}
|
|
17011
17032
|
}
|
|
@@ -17036,7 +17057,7 @@ function registerExportCommand(program2) {
|
|
|
17036
17057
|
}
|
|
17037
17058
|
let projectName;
|
|
17038
17059
|
try {
|
|
17039
|
-
const manifestContent =
|
|
17060
|
+
const manifestContent = readFileSync9(manifestPath, "utf-8");
|
|
17040
17061
|
const manifest = JSON.parse(manifestContent);
|
|
17041
17062
|
projectName = manifest.name ?? "unnamed-project";
|
|
17042
17063
|
} catch {
|
|
@@ -17124,11 +17145,7 @@ function registerReplayCommand(program2) {
|
|
|
17124
17145
|
const result = await client.post(`/api/v1/projects/${projectId}/executions/${executionId}/replay`, { overrides });
|
|
17125
17146
|
output.success(result);
|
|
17126
17147
|
} catch (err) {
|
|
17127
|
-
|
|
17128
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17129
|
-
} else if (err instanceof Error) {
|
|
17130
|
-
output.error("REPLAY_FAILED", err.message);
|
|
17131
|
-
}
|
|
17148
|
+
reportApiError(output, err, "REPLAY_FAILED");
|
|
17132
17149
|
}
|
|
17133
17150
|
});
|
|
17134
17151
|
}
|
|
@@ -17165,11 +17182,7 @@ function registerReplaysCommand(program2) {
|
|
|
17165
17182
|
r.replayOf ?? "-"
|
|
17166
17183
|
]));
|
|
17167
17184
|
} catch (err) {
|
|
17168
|
-
|
|
17169
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17170
|
-
} else if (err instanceof Error) {
|
|
17171
|
-
output.error("REPLAYS_FAILED", err.message);
|
|
17172
|
-
}
|
|
17185
|
+
reportApiError(output, err, "REPLAYS_FAILED");
|
|
17173
17186
|
}
|
|
17174
17187
|
});
|
|
17175
17188
|
}
|
|
@@ -17178,6 +17191,7 @@ var init_replay = __esm(() => {
|
|
|
17178
17191
|
init_api_client();
|
|
17179
17192
|
init_config_store();
|
|
17180
17193
|
init_project_id();
|
|
17194
|
+
init_handle_api_error();
|
|
17181
17195
|
});
|
|
17182
17196
|
|
|
17183
17197
|
// src/commands/kv.ts
|
|
@@ -17224,11 +17238,7 @@ function registerKvCommand(program2) {
|
|
|
17224
17238
|
}
|
|
17225
17239
|
output.table(["Key"], keys.map((k) => [k]));
|
|
17226
17240
|
} catch (err) {
|
|
17227
|
-
|
|
17228
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17229
|
-
} else if (err instanceof Error) {
|
|
17230
|
-
output.error("KV_LIST_FAILED", err.message);
|
|
17231
|
-
}
|
|
17241
|
+
reportApiError(output, err, "KV_LIST_FAILED");
|
|
17232
17242
|
}
|
|
17233
17243
|
});
|
|
17234
17244
|
kv.command("get <key>").description("Get the value for a key").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (key, opts, cmd) => {
|
|
@@ -17241,11 +17251,7 @@ function registerKvCommand(program2) {
|
|
|
17241
17251
|
const result = await client.get(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`);
|
|
17242
17252
|
output.success(result);
|
|
17243
17253
|
} catch (err) {
|
|
17244
|
-
|
|
17245
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17246
|
-
} else if (err instanceof Error) {
|
|
17247
|
-
output.error("KV_GET_FAILED", err.message);
|
|
17248
|
-
}
|
|
17254
|
+
reportApiError(output, err, "KV_GET_FAILED");
|
|
17249
17255
|
}
|
|
17250
17256
|
});
|
|
17251
17257
|
kv.command("set <key> <value>").description("Set a value for a key").option("--project <id>", "Project ID (defaults to dura.json)").option("--ttl <seconds>", "Time-to-live in seconds (0 = no expiry)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (key, valueStr, opts, cmd) => {
|
|
@@ -17268,11 +17274,7 @@ function registerKvCommand(program2) {
|
|
|
17268
17274
|
const result = await client.put(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`, body);
|
|
17269
17275
|
output.success(result);
|
|
17270
17276
|
} catch (err) {
|
|
17271
|
-
|
|
17272
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17273
|
-
} else if (err instanceof Error) {
|
|
17274
|
-
output.error("KV_SET_FAILED", err.message);
|
|
17275
|
-
}
|
|
17277
|
+
reportApiError(output, err, "KV_SET_FAILED");
|
|
17276
17278
|
}
|
|
17277
17279
|
});
|
|
17278
17280
|
kv.command("delete <key>").description("Delete a key from the KV namespace").option("--project <id>", "Project ID (defaults to dura.json)").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) => {
|
|
@@ -17289,11 +17291,7 @@ function registerKvCommand(program2) {
|
|
|
17289
17291
|
await client.delete(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`);
|
|
17290
17292
|
output.success({ deleted: true, key });
|
|
17291
17293
|
} catch (err) {
|
|
17292
|
-
|
|
17293
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17294
|
-
} else if (err instanceof Error) {
|
|
17295
|
-
output.error("KV_DELETE_FAILED", err.message);
|
|
17296
|
-
}
|
|
17294
|
+
reportApiError(output, err, "KV_DELETE_FAILED");
|
|
17297
17295
|
}
|
|
17298
17296
|
});
|
|
17299
17297
|
kv.command("flush").description("Remove all keys in the project KV namespace").option("--project <id>", "Project ID (defaults to dura.json)").option("--confirm", "Required to actually perform the flush").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -17310,11 +17308,7 @@ function registerKvCommand(program2) {
|
|
|
17310
17308
|
await client.delete(`/api/v1/projects/${projectId}/kv`);
|
|
17311
17309
|
output.success({ flushed: true });
|
|
17312
17310
|
} catch (err) {
|
|
17313
|
-
|
|
17314
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17315
|
-
} else if (err instanceof Error) {
|
|
17316
|
-
output.error("KV_FLUSH_FAILED", err.message);
|
|
17317
|
-
}
|
|
17311
|
+
reportApiError(output, err, "KV_FLUSH_FAILED");
|
|
17318
17312
|
}
|
|
17319
17313
|
});
|
|
17320
17314
|
kv.command("stats").description("Show KV usage statistics for the project").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -17327,11 +17321,7 @@ function registerKvCommand(program2) {
|
|
|
17327
17321
|
const stats = await client.get(`/api/v1/projects/${projectId}/kv/stats`);
|
|
17328
17322
|
output.success(stats);
|
|
17329
17323
|
} catch (err) {
|
|
17330
|
-
|
|
17331
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17332
|
-
} else if (err instanceof Error) {
|
|
17333
|
-
output.error("KV_STATS_FAILED", err.message);
|
|
17334
|
-
}
|
|
17324
|
+
reportApiError(output, err, "KV_STATS_FAILED");
|
|
17335
17325
|
}
|
|
17336
17326
|
});
|
|
17337
17327
|
}
|
|
@@ -17340,6 +17330,7 @@ var init_kv2 = __esm(() => {
|
|
|
17340
17330
|
init_api_client();
|
|
17341
17331
|
init_config_store();
|
|
17342
17332
|
init_project_id();
|
|
17333
|
+
init_handle_api_error();
|
|
17343
17334
|
});
|
|
17344
17335
|
|
|
17345
17336
|
// src/commands/webhook.ts
|
|
@@ -17406,9 +17397,7 @@ Webhook relay "${result.name}" created.
|
|
|
17406
17397
|
` + `ID: ${result.id}`);
|
|
17407
17398
|
}
|
|
17408
17399
|
} catch (err) {
|
|
17409
|
-
|
|
17410
|
-
output.error("WEBHOOK_CREATE_FAILED", err.message);
|
|
17411
|
-
}
|
|
17400
|
+
reportApiError(output, err, "WEBHOOK_CREATE_FAILED");
|
|
17412
17401
|
}
|
|
17413
17402
|
});
|
|
17414
17403
|
webhook.command("list").description("List webhook relays").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -17431,9 +17420,7 @@ Webhook relay "${result.name}" created.
|
|
|
17431
17420
|
]));
|
|
17432
17421
|
}
|
|
17433
17422
|
} catch (err) {
|
|
17434
|
-
|
|
17435
|
-
output.error("WEBHOOK_LIST_FAILED", err.message);
|
|
17436
|
-
}
|
|
17423
|
+
reportApiError(output, err, "WEBHOOK_LIST_FAILED");
|
|
17437
17424
|
}
|
|
17438
17425
|
});
|
|
17439
17426
|
webhook.command("show <nameOrId>").description("Show webhook relay details").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17446,9 +17433,7 @@ Webhook relay "${result.name}" created.
|
|
|
17446
17433
|
const result = await client.get(`${webhookBase(opts.project)}/${nameOrId}`);
|
|
17447
17434
|
output.success(result);
|
|
17448
17435
|
} catch (err) {
|
|
17449
|
-
|
|
17450
|
-
output.error("WEBHOOK_SHOW_FAILED", err.message);
|
|
17451
|
-
}
|
|
17436
|
+
reportApiError(output, err, "WEBHOOK_SHOW_FAILED");
|
|
17452
17437
|
}
|
|
17453
17438
|
});
|
|
17454
17439
|
webhook.command("update <nameOrId>").description("Update a webhook relay").requiredOption("--project <id>", "Project ID").option("--name <name>", "New relay name").option("--events <events>", "New comma-separated event types").option("--forward <url>", "New destination URL").option("--transform <json>", "New transform template JSON").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17482,9 +17467,7 @@ Webhook relay "${result.name}" created.
|
|
|
17482
17467
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, patch);
|
|
17483
17468
|
output.success(result);
|
|
17484
17469
|
} catch (err) {
|
|
17485
|
-
|
|
17486
|
-
output.error("WEBHOOK_UPDATE_FAILED", err.message);
|
|
17487
|
-
}
|
|
17470
|
+
reportApiError(output, err, "WEBHOOK_UPDATE_FAILED");
|
|
17488
17471
|
}
|
|
17489
17472
|
});
|
|
17490
17473
|
webhook.command("delete <nameOrId>").description("Delete a webhook relay").requiredOption("--project <id>", "Project ID").option("--confirm", "Confirm this destructive operation").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17501,9 +17484,7 @@ Webhook relay "${result.name}" created.
|
|
|
17501
17484
|
await client.delete(`${webhookBase(opts.project)}/${nameOrId}`);
|
|
17502
17485
|
output.success({ deleted: true, nameOrId });
|
|
17503
17486
|
} catch (err) {
|
|
17504
|
-
|
|
17505
|
-
output.error("WEBHOOK_DELETE_FAILED", err.message);
|
|
17506
|
-
}
|
|
17487
|
+
reportApiError(output, err, "WEBHOOK_DELETE_FAILED");
|
|
17507
17488
|
}
|
|
17508
17489
|
});
|
|
17509
17490
|
webhook.command("enable <nameOrId>").description("Enable a webhook relay").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17516,9 +17497,7 @@ Webhook relay "${result.name}" created.
|
|
|
17516
17497
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, { enabled: true });
|
|
17517
17498
|
output.success(result);
|
|
17518
17499
|
} catch (err) {
|
|
17519
|
-
|
|
17520
|
-
output.error("WEBHOOK_ENABLE_FAILED", err.message);
|
|
17521
|
-
}
|
|
17500
|
+
reportApiError(output, err, "WEBHOOK_ENABLE_FAILED");
|
|
17522
17501
|
}
|
|
17523
17502
|
});
|
|
17524
17503
|
webhook.command("disable <nameOrId>").description("Disable a webhook relay").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17531,9 +17510,7 @@ Webhook relay "${result.name}" created.
|
|
|
17531
17510
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, { enabled: false });
|
|
17532
17511
|
output.success(result);
|
|
17533
17512
|
} catch (err) {
|
|
17534
|
-
|
|
17535
|
-
output.error("WEBHOOK_DISABLE_FAILED", err.message);
|
|
17536
|
-
}
|
|
17513
|
+
reportApiError(output, err, "WEBHOOK_DISABLE_FAILED");
|
|
17537
17514
|
}
|
|
17538
17515
|
});
|
|
17539
17516
|
webhook.command("test <nameOrId>").description("Test a webhook relay with a sample payload").requiredOption("--project <id>", "Project ID").option("--payload <json>", "JSON payload to send", "{}").option("--event <type>", "Event type (sets X-GitHub-Event header for github sources)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17570,9 +17547,7 @@ Webhook relay "${result.name}" created.
|
|
|
17570
17547
|
}
|
|
17571
17548
|
}
|
|
17572
17549
|
} catch (err) {
|
|
17573
|
-
|
|
17574
|
-
output.error("WEBHOOK_TEST_FAILED", err.message);
|
|
17575
|
-
}
|
|
17550
|
+
reportApiError(output, err, "WEBHOOK_TEST_FAILED");
|
|
17576
17551
|
}
|
|
17577
17552
|
});
|
|
17578
17553
|
webhook.command("deliveries <nameOrId>").description("Show recent deliveries for a webhook relay").requiredOption("--project <id>", "Project ID").option("--last <n>", "Number of recent deliveries to show", "10").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (nameOrId, opts, cmd) => {
|
|
@@ -17605,9 +17580,7 @@ Webhook relay "${result.name}" created.
|
|
|
17605
17580
|
]));
|
|
17606
17581
|
}
|
|
17607
17582
|
} catch (err) {
|
|
17608
|
-
|
|
17609
|
-
output.error("WEBHOOK_DELIVERIES_FAILED", err.message);
|
|
17610
|
-
}
|
|
17583
|
+
reportApiError(output, err, "WEBHOOK_DELIVERIES_FAILED");
|
|
17611
17584
|
}
|
|
17612
17585
|
});
|
|
17613
17586
|
}
|
|
@@ -17615,6 +17588,7 @@ var init_webhook = __esm(() => {
|
|
|
17615
17588
|
init_src3();
|
|
17616
17589
|
init_api_client();
|
|
17617
17590
|
init_config_store();
|
|
17591
|
+
init_handle_api_error();
|
|
17618
17592
|
});
|
|
17619
17593
|
|
|
17620
17594
|
// src/commands/template.ts
|
|
@@ -17656,11 +17630,7 @@ function registerTemplateCommand(program2) {
|
|
|
17656
17630
|
String(t.starCount)
|
|
17657
17631
|
]));
|
|
17658
17632
|
} catch (err) {
|
|
17659
|
-
|
|
17660
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17661
|
-
} else if (err instanceof Error) {
|
|
17662
|
-
output.error("LIST_FAILED", err.message);
|
|
17663
|
-
}
|
|
17633
|
+
reportApiError(output, err, "LIST_FAILED");
|
|
17664
17634
|
}
|
|
17665
17635
|
});
|
|
17666
17636
|
const template = program2.command("template").description("Manage project templates");
|
|
@@ -17689,11 +17659,7 @@ function registerTemplateCommand(program2) {
|
|
|
17689
17659
|
}
|
|
17690
17660
|
output.success({ slug: t.slug, bundleRef: t.bundleRef });
|
|
17691
17661
|
} catch (err) {
|
|
17692
|
-
|
|
17693
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17694
|
-
} else if (err instanceof Error) {
|
|
17695
|
-
output.error("SHOW_FAILED", err.message);
|
|
17696
|
-
}
|
|
17662
|
+
reportApiError(output, err, "SHOW_FAILED");
|
|
17697
17663
|
}
|
|
17698
17664
|
});
|
|
17699
17665
|
template.command("publish").description("Publish a project as a template").requiredOption("--name <name>", "Template name").requiredOption("--slug <slug>", "Unique slug").requiredOption("--description <desc>", "Short description").requiredOption("--version <ver>", "Semver version (e.g. 1.0.0)").requiredOption("--bundle-ref <ref>", "Bundle storage reference (bucket/key)").option("--category <cat>", "Category", "general").option("--tags <tags>", "Comma-separated tags").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -17725,11 +17691,7 @@ function registerTemplateCommand(program2) {
|
|
|
17725
17691
|
status: t.status
|
|
17726
17692
|
});
|
|
17727
17693
|
} catch (err) {
|
|
17728
|
-
|
|
17729
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17730
|
-
} else if (err instanceof Error) {
|
|
17731
|
-
output.error("PUBLISH_FAILED", err.message);
|
|
17732
|
-
}
|
|
17694
|
+
reportApiError(output, err, "PUBLISH_FAILED");
|
|
17733
17695
|
}
|
|
17734
17696
|
});
|
|
17735
17697
|
program2.command("fork <slug>").description("Fork a template into a new project").requiredOption("--name <name>", "New project name").option("--org <id>", "Organization ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (slug, opts, cmd) => {
|
|
@@ -17765,11 +17727,7 @@ Set required secrets: ${result.requiredSecrets.join(", ")}`);
|
|
|
17765
17727
|
output.info("Run: dura secrets set <name> <value>");
|
|
17766
17728
|
}
|
|
17767
17729
|
} catch (err) {
|
|
17768
|
-
|
|
17769
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17770
|
-
} else if (err instanceof Error) {
|
|
17771
|
-
output.error("FORK_FAILED", err.message);
|
|
17772
|
-
}
|
|
17730
|
+
reportApiError(output, err, "FORK_FAILED");
|
|
17773
17731
|
}
|
|
17774
17732
|
});
|
|
17775
17733
|
}
|
|
@@ -17777,6 +17735,7 @@ var init_template = __esm(() => {
|
|
|
17777
17735
|
init_src3();
|
|
17778
17736
|
init_api_client();
|
|
17779
17737
|
init_config_store();
|
|
17738
|
+
init_handle_api_error();
|
|
17780
17739
|
});
|
|
17781
17740
|
|
|
17782
17741
|
// src/commands/deployments.ts
|
|
@@ -17818,11 +17777,7 @@ function registerDeploymentsCommand(program2) {
|
|
|
17818
17777
|
}
|
|
17819
17778
|
output.table(["ID", "Status", "Created At"], deploymentList.map((d) => [d.id, d.status, d.createdAt]));
|
|
17820
17779
|
} catch (err) {
|
|
17821
|
-
|
|
17822
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17823
|
-
} else if (err instanceof Error) {
|
|
17824
|
-
output.error("DEPLOYMENTS_LIST_FAILED", err.message);
|
|
17825
|
-
}
|
|
17780
|
+
reportApiError(output, err, "DEPLOYMENTS_LIST_FAILED");
|
|
17826
17781
|
}
|
|
17827
17782
|
});
|
|
17828
17783
|
deployments2.command("get").description("Show details for a specific deployment").option("--project <id>", "Project ID (defaults to dura.json)").requiredOption("--id <deploymentId>", "Deployment ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -17835,11 +17790,7 @@ function registerDeploymentsCommand(program2) {
|
|
|
17835
17790
|
const deployment = await client.get(`/api/v1/projects/${projectId}/deployments/${opts.id}`);
|
|
17836
17791
|
output.success(deployment);
|
|
17837
17792
|
} catch (err) {
|
|
17838
|
-
|
|
17839
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17840
|
-
} else if (err instanceof Error) {
|
|
17841
|
-
output.error("DEPLOYMENTS_GET_FAILED", err.message);
|
|
17842
|
-
}
|
|
17793
|
+
reportApiError(output, err, "DEPLOYMENTS_GET_FAILED");
|
|
17843
17794
|
}
|
|
17844
17795
|
});
|
|
17845
17796
|
}
|
|
@@ -17848,6 +17799,7 @@ var init_deployments2 = __esm(() => {
|
|
|
17848
17799
|
init_api_client();
|
|
17849
17800
|
init_config_store();
|
|
17850
17801
|
init_project_id();
|
|
17802
|
+
init_handle_api_error();
|
|
17851
17803
|
});
|
|
17852
17804
|
|
|
17853
17805
|
// src/commands/diagnose.ts
|
|
@@ -17957,11 +17909,7 @@ Analyzing execution ${targetExecutionId}...`);
|
|
|
17957
17909
|
output.info(formatDiagnosisHuman(diagnosis));
|
|
17958
17910
|
}
|
|
17959
17911
|
} catch (err) {
|
|
17960
|
-
|
|
17961
|
-
output.error(err.code, err.message, err.suggestion);
|
|
17962
|
-
} else if (err instanceof Error) {
|
|
17963
|
-
output.error("DIAGNOSE_FAILED", err.message);
|
|
17964
|
-
}
|
|
17912
|
+
reportApiError(output, err, "DIAGNOSE_FAILED");
|
|
17965
17913
|
}
|
|
17966
17914
|
});
|
|
17967
17915
|
}
|
|
@@ -17970,6 +17918,7 @@ var init_diagnose = __esm(() => {
|
|
|
17970
17918
|
init_api_client();
|
|
17971
17919
|
init_config_store();
|
|
17972
17920
|
init_project_id();
|
|
17921
|
+
init_handle_api_error();
|
|
17973
17922
|
});
|
|
17974
17923
|
|
|
17975
17924
|
// src/commands/create.ts
|
|
@@ -17982,7 +17931,7 @@ import {
|
|
|
17982
17931
|
existsSync as existsSync11,
|
|
17983
17932
|
mkdirSync as mkdirSync6,
|
|
17984
17933
|
writeFileSync as writeFileSync9,
|
|
17985
|
-
readFileSync as
|
|
17934
|
+
readFileSync as readFileSync10,
|
|
17986
17935
|
readdirSync as readdirSync4
|
|
17987
17936
|
} from "node:fs";
|
|
17988
17937
|
import { join as join12, resolve as resolve5, dirname as dirname2 } from "node:path";
|
|
@@ -18055,11 +18004,7 @@ function registerCreateCommand(program2) {
|
|
|
18055
18004
|
try {
|
|
18056
18005
|
generateResult = await client.post(`/api/v1/projects/${projectId}/ai/generate`, { description });
|
|
18057
18006
|
} catch (err) {
|
|
18058
|
-
|
|
18059
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18060
|
-
} else if (err instanceof Error) {
|
|
18061
|
-
output.error("GENERATE_FAILED", err.message);
|
|
18062
|
-
}
|
|
18007
|
+
reportApiError(output, err, "GENERATE_FAILED");
|
|
18063
18008
|
return;
|
|
18064
18009
|
}
|
|
18065
18010
|
output.info(`Generated ${generateResult.files.length} file(s): ${generateResult.files.map((f) => f.path).join(", ")}`);
|
|
@@ -18113,7 +18058,7 @@ function registerAddCommand(program2) {
|
|
|
18113
18058
|
const existingRoutes = getExistingRoutes(projectDir);
|
|
18114
18059
|
let projectConfig = {};
|
|
18115
18060
|
try {
|
|
18116
|
-
projectConfig = JSON.parse(
|
|
18061
|
+
projectConfig = JSON.parse(readFileSync10(duraJsonPath, "utf-8"));
|
|
18117
18062
|
} catch {}
|
|
18118
18063
|
const apiUrl = getApiUrl();
|
|
18119
18064
|
const client = new ApiClient(apiUrl, token);
|
|
@@ -18128,11 +18073,7 @@ function registerAddCommand(program2) {
|
|
|
18128
18073
|
}
|
|
18129
18074
|
});
|
|
18130
18075
|
} catch (err) {
|
|
18131
|
-
|
|
18132
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18133
|
-
} else if (err instanceof Error) {
|
|
18134
|
-
output.error("GENERATE_FAILED", err.message);
|
|
18135
|
-
}
|
|
18076
|
+
reportApiError(output, err, "GENERATE_FAILED");
|
|
18136
18077
|
return;
|
|
18137
18078
|
}
|
|
18138
18079
|
output.info(`Generated ${generateResult.files.length} file(s): ${generateResult.files.map((f) => f.path).join(", ")}`);
|
|
@@ -18163,6 +18104,7 @@ var init_create = __esm(() => {
|
|
|
18163
18104
|
init_src3();
|
|
18164
18105
|
init_api_client();
|
|
18165
18106
|
init_config_store();
|
|
18107
|
+
init_handle_api_error();
|
|
18166
18108
|
});
|
|
18167
18109
|
|
|
18168
18110
|
// src/commands/workflow.ts
|
|
@@ -18207,11 +18149,7 @@ function registerWorkflowsCommand(program2) {
|
|
|
18207
18149
|
d.createdAt
|
|
18208
18150
|
]));
|
|
18209
18151
|
} catch (err) {
|
|
18210
|
-
|
|
18211
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18212
|
-
} else if (err instanceof Error) {
|
|
18213
|
-
output.error("WORKFLOWS_LIST_FAILED", err.message);
|
|
18214
|
-
}
|
|
18152
|
+
reportApiError(output, err, "WORKFLOWS_LIST_FAILED");
|
|
18215
18153
|
}
|
|
18216
18154
|
});
|
|
18217
18155
|
}
|
|
@@ -18240,11 +18178,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18240
18178
|
}
|
|
18241
18179
|
output.info(`Workflow run started: ${result.runId}`);
|
|
18242
18180
|
} catch (err) {
|
|
18243
|
-
|
|
18244
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18245
|
-
} else if (err instanceof Error) {
|
|
18246
|
-
output.error("WORKFLOW_RUN_FAILED", err.message);
|
|
18247
|
-
}
|
|
18181
|
+
reportApiError(output, err, "WORKFLOW_RUN_FAILED");
|
|
18248
18182
|
}
|
|
18249
18183
|
});
|
|
18250
18184
|
workflow.command("runs <name>").description("List workflow runs").requiredOption("--project <id>", "Project ID").option("--status <status>", "Filter by status (pending/running/completed/failed)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (name, opts, cmd) => {
|
|
@@ -18268,11 +18202,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18268
18202
|
}
|
|
18269
18203
|
output.table(["ID", "Status", "Trigger", "Created"], runs.map((r) => [r.id, r.status, r.triggerType, r.createdAt]));
|
|
18270
18204
|
} catch (err) {
|
|
18271
|
-
|
|
18272
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18273
|
-
} else if (err instanceof Error) {
|
|
18274
|
-
output.error("WORKFLOW_RUNS_FAILED", err.message);
|
|
18275
|
-
}
|
|
18205
|
+
reportApiError(output, err, "WORKFLOW_RUNS_FAILED");
|
|
18276
18206
|
}
|
|
18277
18207
|
});
|
|
18278
18208
|
workflow.command("cancel <run-id>").description("Cancel a running workflow").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").option("--confirm", "Confirm the destructive cancel operation").action(async (runId, opts, cmd) => {
|
|
@@ -18289,11 +18219,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18289
18219
|
await client.post(`/api/v1/projects/${opts.project}/workflow-runs/${encodeURIComponent(runId)}/cancel`, {});
|
|
18290
18220
|
output.info(`Workflow run ${runId} cancelled.`);
|
|
18291
18221
|
} catch (err) {
|
|
18292
|
-
|
|
18293
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18294
|
-
} else if (err instanceof Error) {
|
|
18295
|
-
output.error("WORKFLOW_CANCEL_FAILED", err.message);
|
|
18296
|
-
}
|
|
18222
|
+
reportApiError(output, err, "WORKFLOW_CANCEL_FAILED");
|
|
18297
18223
|
}
|
|
18298
18224
|
});
|
|
18299
18225
|
}
|
|
@@ -18325,11 +18251,7 @@ function registerApprovalsCommand(program2) {
|
|
|
18325
18251
|
a.createdAt
|
|
18326
18252
|
]));
|
|
18327
18253
|
} catch (err) {
|
|
18328
|
-
|
|
18329
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18330
|
-
} else if (err instanceof Error) {
|
|
18331
|
-
output.error("APPROVALS_LIST_FAILED", err.message);
|
|
18332
|
-
}
|
|
18254
|
+
reportApiError(output, err, "APPROVALS_LIST_FAILED");
|
|
18333
18255
|
}
|
|
18334
18256
|
});
|
|
18335
18257
|
}
|
|
@@ -18344,11 +18266,7 @@ function registerApproveCommand(program2) {
|
|
|
18344
18266
|
await client.post(`/api/v1/projects/${opts.project}/approvals/${encodeURIComponent(approvalId)}/approve`, { decidedBy: opts.decidedBy });
|
|
18345
18267
|
output.info(`Approval ${approvalId} approved.`);
|
|
18346
18268
|
} catch (err) {
|
|
18347
|
-
|
|
18348
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18349
|
-
} else if (err instanceof Error) {
|
|
18350
|
-
output.error("APPROVE_FAILED", err.message);
|
|
18351
|
-
}
|
|
18269
|
+
reportApiError(output, err, "APPROVE_FAILED");
|
|
18352
18270
|
}
|
|
18353
18271
|
});
|
|
18354
18272
|
}
|
|
@@ -18363,11 +18281,7 @@ function registerRejectCommand(program2) {
|
|
|
18363
18281
|
await client.post(`/api/v1/projects/${opts.project}/approvals/${encodeURIComponent(approvalId)}/reject`, { decidedBy: opts.decidedBy, reason: opts.reason });
|
|
18364
18282
|
output.info(`Approval ${approvalId} rejected.`);
|
|
18365
18283
|
} catch (err) {
|
|
18366
|
-
|
|
18367
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18368
|
-
} else if (err instanceof Error) {
|
|
18369
|
-
output.error("REJECT_FAILED", err.message);
|
|
18370
|
-
}
|
|
18284
|
+
reportApiError(output, err, "REJECT_FAILED");
|
|
18371
18285
|
}
|
|
18372
18286
|
});
|
|
18373
18287
|
}
|
|
@@ -18375,6 +18289,7 @@ var init_workflow = __esm(() => {
|
|
|
18375
18289
|
init_src3();
|
|
18376
18290
|
init_api_client();
|
|
18377
18291
|
init_config_store();
|
|
18292
|
+
init_handle_api_error();
|
|
18378
18293
|
});
|
|
18379
18294
|
|
|
18380
18295
|
// src/commands/env.ts
|
|
@@ -18416,11 +18331,7 @@ function registerEnvCommand(program2) {
|
|
|
18416
18331
|
});
|
|
18417
18332
|
output.success(env2);
|
|
18418
18333
|
} catch (err) {
|
|
18419
|
-
|
|
18420
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18421
|
-
} else if (err instanceof Error) {
|
|
18422
|
-
output.error("ENV_CREATE_FAILED", err.message);
|
|
18423
|
-
}
|
|
18334
|
+
reportApiError(output, err, "ENV_CREATE_FAILED");
|
|
18424
18335
|
}
|
|
18425
18336
|
});
|
|
18426
18337
|
env.command("list").description("List all environments for a project").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -18433,11 +18344,7 @@ function registerEnvCommand(program2) {
|
|
|
18433
18344
|
const envs = await client.get(`/api/v1/projects/${projectId}/environments`);
|
|
18434
18345
|
output.success(envs);
|
|
18435
18346
|
} catch (err) {
|
|
18436
|
-
|
|
18437
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18438
|
-
} else if (err instanceof Error) {
|
|
18439
|
-
output.error("ENV_LIST_FAILED", err.message);
|
|
18440
|
-
}
|
|
18347
|
+
reportApiError(output, err, "ENV_LIST_FAILED");
|
|
18441
18348
|
}
|
|
18442
18349
|
});
|
|
18443
18350
|
env.command("delete <name>").description("Delete an environment").option("--project <id>", "Project ID (defaults to dura.json)").option("--env-id <id>", "Environment ID (alternative to name)").option("--confirm", "Confirm deletion (required for destructive operation)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (name, opts, cmd) => {
|
|
@@ -18464,11 +18371,7 @@ function registerEnvCommand(program2) {
|
|
|
18464
18371
|
await client.delete(`/api/v1/projects/${projectId}/environments/${envId}`);
|
|
18465
18372
|
output.success({ deleted: true, name });
|
|
18466
18373
|
} catch (err) {
|
|
18467
|
-
|
|
18468
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18469
|
-
} else if (err instanceof Error) {
|
|
18470
|
-
output.error("ENV_DELETE_FAILED", err.message);
|
|
18471
|
-
}
|
|
18374
|
+
reportApiError(output, err, "ENV_DELETE_FAILED");
|
|
18472
18375
|
}
|
|
18473
18376
|
});
|
|
18474
18377
|
env.command("diff <env1> <env2>").description("Compare two environments").option("--project <id>", "Project ID (defaults to dura.json)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (env1, env2, opts, cmd) => {
|
|
@@ -18496,11 +18399,7 @@ function registerEnvCommand(program2) {
|
|
|
18496
18399
|
};
|
|
18497
18400
|
output.success(diff);
|
|
18498
18401
|
} catch (err) {
|
|
18499
|
-
|
|
18500
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18501
|
-
} else if (err instanceof Error) {
|
|
18502
|
-
output.error("ENV_DIFF_FAILED", err.message);
|
|
18503
|
-
}
|
|
18402
|
+
reportApiError(output, err, "ENV_DIFF_FAILED");
|
|
18504
18403
|
}
|
|
18505
18404
|
});
|
|
18506
18405
|
}
|
|
@@ -18553,11 +18452,7 @@ function registerPromoteCommand(program2) {
|
|
|
18553
18452
|
});
|
|
18554
18453
|
output.success(promotion);
|
|
18555
18454
|
} catch (err) {
|
|
18556
|
-
|
|
18557
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18558
|
-
} else if (err instanceof Error) {
|
|
18559
|
-
output.error("PROMOTE_FAILED", err.message);
|
|
18560
|
-
}
|
|
18455
|
+
reportApiError(output, err, "PROMOTE_FAILED");
|
|
18561
18456
|
}
|
|
18562
18457
|
});
|
|
18563
18458
|
}
|
|
@@ -18581,11 +18476,7 @@ function registerCanaryCommand(program2) {
|
|
|
18581
18476
|
const canary2 = await client.get(`/api/v1/projects/${projectId}/canary?envId=${opts.env}`);
|
|
18582
18477
|
output.success(canary2);
|
|
18583
18478
|
} catch (err) {
|
|
18584
|
-
|
|
18585
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18586
|
-
} else if (err instanceof Error) {
|
|
18587
|
-
output.error("CANARY_STATUS_FAILED", err.message);
|
|
18588
|
-
}
|
|
18479
|
+
reportApiError(output, err, "CANARY_STATUS_FAILED");
|
|
18589
18480
|
}
|
|
18590
18481
|
});
|
|
18591
18482
|
canary.command("complete").description("Force-complete an active canary (100% traffic to new)").option("--project <id>", "Project ID (defaults to dura.json)").requiredOption("--canary-id <id>", "Canary deployment ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -18606,11 +18497,7 @@ function registerCanaryCommand(program2) {
|
|
|
18606
18497
|
const canary2 = await client.post(`/api/v1/projects/${projectId}/canary/complete`, { canaryId: opts.canaryId });
|
|
18607
18498
|
output.success(canary2);
|
|
18608
18499
|
} catch (err) {
|
|
18609
|
-
|
|
18610
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18611
|
-
} else if (err instanceof Error) {
|
|
18612
|
-
output.error("CANARY_COMPLETE_FAILED", err.message);
|
|
18613
|
-
}
|
|
18500
|
+
reportApiError(output, err, "CANARY_COMPLETE_FAILED");
|
|
18614
18501
|
}
|
|
18615
18502
|
});
|
|
18616
18503
|
canary.command("rollback").description("Force-rollback an active canary (restore old deployment)").option("--project <id>", "Project ID (defaults to dura.json)").requiredOption("--canary-id <id>", "Canary deployment ID").option("--reason <reason>", "Reason for rollback").option("--confirm", "Confirm rollback (required)").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -18635,11 +18522,7 @@ function registerCanaryCommand(program2) {
|
|
|
18635
18522
|
const canary2 = await client.post(`/api/v1/projects/${projectId}/canary/rollback`, { canaryId: opts.canaryId, reason: opts.reason });
|
|
18636
18523
|
output.success(canary2);
|
|
18637
18524
|
} catch (err) {
|
|
18638
|
-
|
|
18639
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18640
|
-
} else if (err instanceof Error) {
|
|
18641
|
-
output.error("CANARY_ROLLBACK_FAILED", err.message);
|
|
18642
|
-
}
|
|
18525
|
+
reportApiError(output, err, "CANARY_ROLLBACK_FAILED");
|
|
18643
18526
|
}
|
|
18644
18527
|
});
|
|
18645
18528
|
}
|
|
@@ -18667,6 +18550,7 @@ var init_env = __esm(() => {
|
|
|
18667
18550
|
init_api_client();
|
|
18668
18551
|
init_config_store();
|
|
18669
18552
|
init_project_id();
|
|
18553
|
+
init_handle_api_error();
|
|
18670
18554
|
});
|
|
18671
18555
|
|
|
18672
18556
|
// src/commands/reports.ts
|
|
@@ -18983,16 +18867,13 @@ function parseChannelSpec(spec) {
|
|
|
18983
18867
|
return null;
|
|
18984
18868
|
}
|
|
18985
18869
|
function handleError(err, output, defaultCode) {
|
|
18986
|
-
|
|
18987
|
-
output.error(err.code, err.message, err.suggestion);
|
|
18988
|
-
} else if (err instanceof Error) {
|
|
18989
|
-
output.error(defaultCode, err.message);
|
|
18990
|
-
}
|
|
18870
|
+
reportApiError(output, err, defaultCode);
|
|
18991
18871
|
}
|
|
18992
18872
|
var init_reports = __esm(() => {
|
|
18993
18873
|
init_src3();
|
|
18994
18874
|
init_api_client();
|
|
18995
18875
|
init_config_store();
|
|
18876
|
+
init_handle_api_error();
|
|
18996
18877
|
});
|
|
18997
18878
|
|
|
18998
18879
|
// src/commands/heal.ts
|
|
@@ -19110,11 +18991,7 @@ Healing configuration:
|
|
|
19110
18991
|
}
|
|
19111
18992
|
}
|
|
19112
18993
|
} catch (err) {
|
|
19113
|
-
|
|
19114
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19115
|
-
} else if (err instanceof Error) {
|
|
19116
|
-
output.error("HEAL_CONFIG_FAILED", err.message);
|
|
19117
|
-
}
|
|
18994
|
+
reportApiError(output, err, "HEAL_CONFIG_FAILED");
|
|
19118
18995
|
}
|
|
19119
18996
|
});
|
|
19120
18997
|
heal.command("list").description("List healing records").requiredOption("--project <id>", "Project ID").option("--status <status>", "Filter by status (e.g. suggested, deployed)").option("--limit <n>", "Max records to show", parseInt).option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (opts, cmd) => {
|
|
@@ -19146,11 +19023,7 @@ ${records.length} healing record(s):
|
|
|
19146
19023
|
}
|
|
19147
19024
|
}
|
|
19148
19025
|
} catch (err) {
|
|
19149
|
-
|
|
19150
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19151
|
-
} else if (err instanceof Error) {
|
|
19152
|
-
output.error("HEAL_LIST_FAILED", err.message);
|
|
19153
|
-
}
|
|
19026
|
+
reportApiError(output, err, "HEAL_LIST_FAILED");
|
|
19154
19027
|
}
|
|
19155
19028
|
});
|
|
19156
19029
|
heal.command("show <record-id>").description("Show healing record details").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (recordId, opts, cmd) => {
|
|
@@ -19169,11 +19042,7 @@ ${records.length} healing record(s):
|
|
|
19169
19042
|
${formatRecord(record)}`);
|
|
19170
19043
|
}
|
|
19171
19044
|
} catch (err) {
|
|
19172
|
-
|
|
19173
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19174
|
-
} else if (err instanceof Error) {
|
|
19175
|
-
output.error("HEAL_SHOW_FAILED", err.message);
|
|
19176
|
-
}
|
|
19045
|
+
reportApiError(output, err, "HEAL_SHOW_FAILED");
|
|
19177
19046
|
}
|
|
19178
19047
|
});
|
|
19179
19048
|
heal.command("trigger <execution-id>").description("Manually trigger healing for a failed execution").requiredOption("--project <id>", "Project ID").requiredOption("--automation <name>", "Automation name").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (executionId, opts, cmd) => {
|
|
@@ -19193,11 +19062,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19193
19062
|
output.info(`Status: ${record.status}`);
|
|
19194
19063
|
}
|
|
19195
19064
|
} catch (err) {
|
|
19196
|
-
|
|
19197
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19198
|
-
} else if (err instanceof Error) {
|
|
19199
|
-
output.error("HEAL_TRIGGER_FAILED", err.message);
|
|
19200
|
-
}
|
|
19065
|
+
reportApiError(output, err, "HEAL_TRIGGER_FAILED");
|
|
19201
19066
|
}
|
|
19202
19067
|
});
|
|
19203
19068
|
heal.command("approve <record-id>").description("Approve a suggested fix and deploy it").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (recordId, opts, cmd) => {
|
|
@@ -19215,11 +19080,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19215
19080
|
output.info(`Fix ${recordId} approved and queued for deployment.`);
|
|
19216
19081
|
}
|
|
19217
19082
|
} catch (err) {
|
|
19218
|
-
|
|
19219
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19220
|
-
} else if (err instanceof Error) {
|
|
19221
|
-
output.error("HEAL_APPROVE_FAILED", err.message);
|
|
19222
|
-
}
|
|
19083
|
+
reportApiError(output, err, "HEAL_APPROVE_FAILED");
|
|
19223
19084
|
}
|
|
19224
19085
|
});
|
|
19225
19086
|
heal.command("reject <record-id>").description("Reject a suggested fix").requiredOption("--project <id>", "Project ID").option("--reason <reason>", "Reason for rejection").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (recordId, opts, cmd) => {
|
|
@@ -19237,11 +19098,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19237
19098
|
output.info(`Fix ${recordId} rejected.`);
|
|
19238
19099
|
}
|
|
19239
19100
|
} catch (err) {
|
|
19240
|
-
|
|
19241
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19242
|
-
} else if (err instanceof Error) {
|
|
19243
|
-
output.error("HEAL_REJECT_FAILED", err.message);
|
|
19244
|
-
}
|
|
19101
|
+
reportApiError(output, err, "HEAL_REJECT_FAILED");
|
|
19245
19102
|
}
|
|
19246
19103
|
});
|
|
19247
19104
|
heal.command("rollback <record-id>").description("Rollback a deployed fix").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (recordId, opts, cmd) => {
|
|
@@ -19259,11 +19116,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19259
19116
|
output.info(`Fix ${recordId} rolled back.`);
|
|
19260
19117
|
}
|
|
19261
19118
|
} catch (err) {
|
|
19262
|
-
|
|
19263
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19264
|
-
} else if (err instanceof Error) {
|
|
19265
|
-
output.error("HEAL_ROLLBACK_FAILED", err.message);
|
|
19266
|
-
}
|
|
19119
|
+
reportApiError(output, err, "HEAL_ROLLBACK_FAILED");
|
|
19267
19120
|
}
|
|
19268
19121
|
});
|
|
19269
19122
|
heal.command("diff <record-id>").description("Show the generated code patch (diff view)").requiredOption("--project <id>", "Project ID").option("--api-url <url>", "API base URL").option("--token <token>", "Auth token").action(async (recordId, opts, cmd) => {
|
|
@@ -19287,11 +19140,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19287
19140
|
${formatDiff(record)}`);
|
|
19288
19141
|
}
|
|
19289
19142
|
} catch (err) {
|
|
19290
|
-
|
|
19291
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19292
|
-
} else if (err instanceof Error) {
|
|
19293
|
-
output.error("HEAL_DIFF_FAILED", err.message);
|
|
19294
|
-
}
|
|
19143
|
+
reportApiError(output, err, "HEAL_DIFF_FAILED");
|
|
19295
19144
|
}
|
|
19296
19145
|
});
|
|
19297
19146
|
}
|
|
@@ -19299,10 +19148,11 @@ var init_heal = __esm(() => {
|
|
|
19299
19148
|
init_src3();
|
|
19300
19149
|
init_api_client();
|
|
19301
19150
|
init_config_store();
|
|
19151
|
+
init_handle_api_error();
|
|
19302
19152
|
});
|
|
19303
19153
|
|
|
19304
19154
|
// src/lib/skill-installer.ts
|
|
19305
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as
|
|
19155
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
|
|
19306
19156
|
import { join as join13, dirname as dirname3 } from "node:path";
|
|
19307
19157
|
import { homedir as homedir2 } from "node:os";
|
|
19308
19158
|
import { fileURLToPath } from "node:url";
|
|
@@ -19325,7 +19175,7 @@ function installSkills(targetDir) {
|
|
|
19325
19175
|
for (const file of SKILL_FILES) {
|
|
19326
19176
|
const sourcePath = join13(sourceDir, file);
|
|
19327
19177
|
const targetPath = join13(targetDir, file);
|
|
19328
|
-
const content =
|
|
19178
|
+
const content = readFileSync11(sourcePath, "utf-8");
|
|
19329
19179
|
writeFileSync10(targetPath, content, "utf-8");
|
|
19330
19180
|
installedFiles.push(targetPath);
|
|
19331
19181
|
}
|
|
@@ -19484,11 +19334,7 @@ function registerProjectsCommand(program2) {
|
|
|
19484
19334
|
const project = await client.get(`/api/v1/orgs/${orgId}/projects/${projectId}`);
|
|
19485
19335
|
output.success(project);
|
|
19486
19336
|
} catch (err) {
|
|
19487
|
-
|
|
19488
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19489
|
-
} else if (err instanceof Error) {
|
|
19490
|
-
output.error("PROJECTS_GET_FAILED", err.message);
|
|
19491
|
-
}
|
|
19337
|
+
reportApiError(output, err, "PROJECTS_GET_FAILED");
|
|
19492
19338
|
}
|
|
19493
19339
|
});
|
|
19494
19340
|
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) => {
|
|
@@ -19522,11 +19368,7 @@ function registerProjectsCommand(program2) {
|
|
|
19522
19368
|
]));
|
|
19523
19369
|
}
|
|
19524
19370
|
} catch (err) {
|
|
19525
|
-
|
|
19526
|
-
output.error(err.code, err.message, err.suggestion);
|
|
19527
|
-
} else if (err instanceof Error) {
|
|
19528
|
-
output.error("PROJECTS_LIST_FAILED", err.message);
|
|
19529
|
-
}
|
|
19371
|
+
reportApiError(output, err, "PROJECTS_LIST_FAILED");
|
|
19530
19372
|
}
|
|
19531
19373
|
});
|
|
19532
19374
|
}
|
|
@@ -19534,6 +19376,7 @@ var init_projects2 = __esm(() => {
|
|
|
19534
19376
|
init_src3();
|
|
19535
19377
|
init_api_client();
|
|
19536
19378
|
init_config_store();
|
|
19379
|
+
init_handle_api_error();
|
|
19537
19380
|
});
|
|
19538
19381
|
|
|
19539
19382
|
// src/index.ts
|
|
@@ -19575,6 +19418,7 @@ async function registerAllCommands(program2) {
|
|
|
19575
19418
|
const { registerTestCommand: registerTestCommand2 } = await Promise.resolve().then(() => (init_test(), exports_test));
|
|
19576
19419
|
const { registerDomainsCommand: registerDomainsCommand2 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
|
|
19577
19420
|
const { registerEndpointKeysCommand: registerEndpointKeysCommand2 } = await Promise.resolve().then(() => (init_endpoint_keys2(), exports_endpoint_keys));
|
|
19421
|
+
const { registerEventsCommand: registerEventsCommand2 } = await Promise.resolve().then(() => (init_events(), exports_events));
|
|
19578
19422
|
const { registerUsageCommand: registerUsageCommand2 } = await Promise.resolve().then(() => (init_usage(), exports_usage));
|
|
19579
19423
|
const { registerMarketplaceCommand: registerMarketplaceCommand2 } = await Promise.resolve().then(() => (init_marketplace2(), exports_marketplace));
|
|
19580
19424
|
const { registerExportCommand: registerExportCommand2 } = await Promise.resolve().then(() => (init_export(), exports_export));
|
|
@@ -19619,6 +19463,7 @@ async function registerAllCommands(program2) {
|
|
|
19619
19463
|
registerTestCommand2(program2);
|
|
19620
19464
|
registerRunCommand2(program2);
|
|
19621
19465
|
registerScheduleCommand2(program2);
|
|
19466
|
+
registerEventsCommand2(program2);
|
|
19622
19467
|
registerStatusCommand2(program2);
|
|
19623
19468
|
registerLogsCommand2(program2);
|
|
19624
19469
|
registerUsageCommand2(program2);
|
|
@@ -19640,7 +19485,7 @@ async function registerAllCommands(program2) {
|
|
|
19640
19485
|
registerOpenApiCommand2(program2);
|
|
19641
19486
|
return program2;
|
|
19642
19487
|
}
|
|
19643
|
-
var CLI_VERSION = "0.3.
|
|
19488
|
+
var CLI_VERSION = "0.3.1";
|
|
19644
19489
|
var init_src3 = __esm(() => {
|
|
19645
19490
|
init_esm();
|
|
19646
19491
|
if (import.meta.url === `file://${realpathSync(process.argv[1] ?? "").replace(/\\/g, "/")}`) {
|
|
@@ -19657,4 +19502,4 @@ export {
|
|
|
19657
19502
|
CLI_VERSION
|
|
19658
19503
|
};
|
|
19659
19504
|
|
|
19660
|
-
//# debugId=
|
|
19505
|
+
//# debugId=A22178BD000AEBBE64756E2164756E21
|