@dura-run/cli 0.3.0 → 0.3.2
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 +239 -366
- package/package.json +1 -1
package/dist/dura.js
CHANGED
|
@@ -2834,6 +2834,33 @@ var init_hello = __esm(() => {
|
|
|
2834
2834
|
HELLO_TEMPLATE = GET_TEMPLATE;
|
|
2835
2835
|
});
|
|
2836
2836
|
|
|
2837
|
+
// src/templates/package.json.ts
|
|
2838
|
+
function packageJsonTemplate(projectName) {
|
|
2839
|
+
return JSON.stringify({
|
|
2840
|
+
name: projectName,
|
|
2841
|
+
version: "0.0.0",
|
|
2842
|
+
private: true,
|
|
2843
|
+
type: "module"
|
|
2844
|
+
}, null, 2) + `
|
|
2845
|
+
`;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
// src/lib/handle-api-error.ts
|
|
2849
|
+
function reportApiError(output, err, fallbackCode) {
|
|
2850
|
+
if (err instanceof ApiClientError) {
|
|
2851
|
+
output.error(err.code, err.message, err.suggestion);
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
if (err instanceof Error) {
|
|
2855
|
+
output.error(fallbackCode, err.message);
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
output.error(fallbackCode, String(err));
|
|
2859
|
+
}
|
|
2860
|
+
var init_handle_api_error = __esm(() => {
|
|
2861
|
+
init_api_client();
|
|
2862
|
+
});
|
|
2863
|
+
|
|
2837
2864
|
// src/commands/new.ts
|
|
2838
2865
|
var exports_new = {};
|
|
2839
2866
|
__export(exports_new, {
|
|
@@ -2890,17 +2917,14 @@ function registerNewCommand(program2) {
|
|
|
2890
2917
|
Set required secrets: ${result.requiredSecrets.join(", ")}`);
|
|
2891
2918
|
}
|
|
2892
2919
|
} 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
|
-
}
|
|
2920
|
+
reportApiError(output, err, "FORK_FAILED");
|
|
2898
2921
|
}
|
|
2899
2922
|
return;
|
|
2900
2923
|
}
|
|
2901
2924
|
mkdirSync2(join2(projectDir, "routes"), { recursive: true });
|
|
2902
2925
|
mkdirSync2(join2(projectDir, "jobs"), { recursive: true });
|
|
2903
2926
|
writeFileSync2(join2(projectDir, "dura.json"), duraJsonTemplate(name, triggerKind));
|
|
2927
|
+
writeFileSync2(join2(projectDir, "package.json"), packageJsonTemplate(name));
|
|
2904
2928
|
writeFileSync2(join2(projectDir, "routes", "hello.ts"), helloTemplate(triggerKind));
|
|
2905
2929
|
writeFileSync2(join2(projectDir, ".gitignore"), GITIGNORE_CONTENT);
|
|
2906
2930
|
const token = getAuthToken();
|
|
@@ -2934,7 +2958,13 @@ Set required secrets: ${result.requiredSecrets.join(", ")}`);
|
|
|
2934
2958
|
created: true,
|
|
2935
2959
|
name,
|
|
2936
2960
|
path: projectDir,
|
|
2937
|
-
files: [
|
|
2961
|
+
files: [
|
|
2962
|
+
"dura.json",
|
|
2963
|
+
"package.json",
|
|
2964
|
+
"routes/hello.ts",
|
|
2965
|
+
"jobs/",
|
|
2966
|
+
".gitignore"
|
|
2967
|
+
]
|
|
2938
2968
|
});
|
|
2939
2969
|
});
|
|
2940
2970
|
}
|
|
@@ -2948,6 +2978,7 @@ var init_new = __esm(() => {
|
|
|
2948
2978
|
init_hello();
|
|
2949
2979
|
init_api_client();
|
|
2950
2980
|
init_config_store();
|
|
2981
|
+
init_handle_api_error();
|
|
2951
2982
|
});
|
|
2952
2983
|
|
|
2953
2984
|
// src/lib/project-id.ts
|
|
@@ -3002,9 +3033,7 @@ function registerSecretsCommand(program2) {
|
|
|
3002
3033
|
const result = await client.put(`/api/v1/projects/${projectId}/secrets`, { name, value });
|
|
3003
3034
|
output.success(result);
|
|
3004
3035
|
} catch (err) {
|
|
3005
|
-
|
|
3006
|
-
output.error("SECRET_SET_FAILED", err.message);
|
|
3007
|
-
}
|
|
3036
|
+
reportApiError(output, err, "SECRET_SET_FAILED");
|
|
3008
3037
|
}
|
|
3009
3038
|
});
|
|
3010
3039
|
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 +3046,7 @@ function registerSecretsCommand(program2) {
|
|
|
3017
3046
|
const result = await client.get(`/api/v1/projects/${projectId}/secrets`);
|
|
3018
3047
|
output.table(["Name", "Created", "Updated"], result.map((s) => [s.name, s.createdAt, s.updatedAt]));
|
|
3019
3048
|
} catch (err) {
|
|
3020
|
-
|
|
3021
|
-
output.error("SECRET_LIST_FAILED", err.message);
|
|
3022
|
-
}
|
|
3049
|
+
reportApiError(output, err, "SECRET_LIST_FAILED");
|
|
3023
3050
|
}
|
|
3024
3051
|
});
|
|
3025
3052
|
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 +3063,7 @@ function registerSecretsCommand(program2) {
|
|
|
3036
3063
|
await client.delete(`/api/v1/projects/${projectId}/secrets/${name}`);
|
|
3037
3064
|
output.success({ deleted: true, name });
|
|
3038
3065
|
} catch (err) {
|
|
3039
|
-
|
|
3040
|
-
output.error("SECRET_REMOVE_FAILED", err.message);
|
|
3041
|
-
}
|
|
3066
|
+
reportApiError(output, err, "SECRET_REMOVE_FAILED");
|
|
3042
3067
|
}
|
|
3043
3068
|
});
|
|
3044
3069
|
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 +3084,7 @@ function registerSecretsCommand(program2) {
|
|
|
3059
3084
|
count: Object.keys(values).length
|
|
3060
3085
|
});
|
|
3061
3086
|
} catch (err) {
|
|
3062
|
-
|
|
3063
|
-
output.error("SECRET_PULL_FAILED", err.message);
|
|
3064
|
-
}
|
|
3087
|
+
reportApiError(output, err, "SECRET_PULL_FAILED");
|
|
3065
3088
|
}
|
|
3066
3089
|
});
|
|
3067
3090
|
}
|
|
@@ -3069,6 +3092,7 @@ var init_secrets = __esm(() => {
|
|
|
3069
3092
|
init_src3();
|
|
3070
3093
|
init_api_client();
|
|
3071
3094
|
init_config_store();
|
|
3095
|
+
init_handle_api_error();
|
|
3072
3096
|
init_project_id();
|
|
3073
3097
|
});
|
|
3074
3098
|
|
|
@@ -13884,9 +13908,7 @@ function registerConfigCommand(program2) {
|
|
|
13884
13908
|
setManifestValue(opts.dir, path, parsed);
|
|
13885
13909
|
output.success({ path, value: parsed });
|
|
13886
13910
|
} catch (err) {
|
|
13887
|
-
|
|
13888
|
-
output.error("CONFIG_SET_FAILED", err.message);
|
|
13889
|
-
}
|
|
13911
|
+
reportApiError(output, err, "CONFIG_SET_FAILED");
|
|
13890
13912
|
}
|
|
13891
13913
|
});
|
|
13892
13914
|
config.command("get <path>").description("Get a config value using dot-path notation").option("--dir <path>", "Project directory", ".").action((path, opts, cmd) => {
|
|
@@ -13899,15 +13921,14 @@ function registerConfigCommand(program2) {
|
|
|
13899
13921
|
}
|
|
13900
13922
|
output.success({ path, value });
|
|
13901
13923
|
} catch (err) {
|
|
13902
|
-
|
|
13903
|
-
output.error("CONFIG_GET_FAILED", err.message);
|
|
13904
|
-
}
|
|
13924
|
+
reportApiError(output, err, "CONFIG_GET_FAILED");
|
|
13905
13925
|
}
|
|
13906
13926
|
});
|
|
13907
13927
|
}
|
|
13908
13928
|
var init_config = __esm(() => {
|
|
13909
13929
|
init_src3();
|
|
13910
13930
|
init_manifest2();
|
|
13931
|
+
init_handle_api_error();
|
|
13911
13932
|
});
|
|
13912
13933
|
|
|
13913
13934
|
// src/commands/status.ts
|
|
@@ -13929,9 +13950,7 @@ function registerStatusCommand(program2) {
|
|
|
13929
13950
|
const project = await client.get(`/api/v1/orgs/${opts.org}/projects/${opts.project}`);
|
|
13930
13951
|
output.success(project);
|
|
13931
13952
|
} catch (err) {
|
|
13932
|
-
|
|
13933
|
-
output.error("STATUS_FAILED", err.message);
|
|
13934
|
-
}
|
|
13953
|
+
reportApiError(output, err, "STATUS_FAILED");
|
|
13935
13954
|
}
|
|
13936
13955
|
});
|
|
13937
13956
|
}
|
|
@@ -13939,6 +13958,7 @@ var init_status = __esm(() => {
|
|
|
13939
13958
|
init_src3();
|
|
13940
13959
|
init_api_client();
|
|
13941
13960
|
init_config_store();
|
|
13961
|
+
init_handle_api_error();
|
|
13942
13962
|
});
|
|
13943
13963
|
|
|
13944
13964
|
// src/commands/audit.ts
|
|
@@ -13970,9 +13990,7 @@ function registerAuditCommand(program2) {
|
|
|
13970
13990
|
e.userId
|
|
13971
13991
|
]));
|
|
13972
13992
|
} catch (err) {
|
|
13973
|
-
|
|
13974
|
-
output.error("AUDIT_FAILED", err.message);
|
|
13975
|
-
}
|
|
13993
|
+
reportApiError(output, err, "AUDIT_FAILED");
|
|
13976
13994
|
}
|
|
13977
13995
|
});
|
|
13978
13996
|
}
|
|
@@ -13980,6 +13998,7 @@ var init_audit = __esm(() => {
|
|
|
13980
13998
|
init_src3();
|
|
13981
13999
|
init_api_client();
|
|
13982
14000
|
init_config_store();
|
|
14001
|
+
init_handle_api_error();
|
|
13983
14002
|
});
|
|
13984
14003
|
|
|
13985
14004
|
// src/lib/manifest-generator.ts
|
|
@@ -14230,11 +14249,7 @@ Live at:`);
|
|
|
14230
14249
|
}
|
|
14231
14250
|
}
|
|
14232
14251
|
} 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
|
-
}
|
|
14252
|
+
reportApiError(output, err, "DEPLOY_FAILED");
|
|
14238
14253
|
}
|
|
14239
14254
|
});
|
|
14240
14255
|
}
|
|
@@ -14244,6 +14259,7 @@ var init_deploy = __esm(() => {
|
|
|
14244
14259
|
init_config_store();
|
|
14245
14260
|
init_bundler();
|
|
14246
14261
|
init_manifest2();
|
|
14262
|
+
init_handle_api_error();
|
|
14247
14263
|
});
|
|
14248
14264
|
|
|
14249
14265
|
// src/commands/rollback.ts
|
|
@@ -14273,11 +14289,7 @@ function registerRollbackCommand(program2) {
|
|
|
14273
14289
|
activatedAt: deployment.activatedAt
|
|
14274
14290
|
});
|
|
14275
14291
|
} 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
|
-
}
|
|
14292
|
+
reportApiError(output, err, "ROLLBACK_FAILED");
|
|
14281
14293
|
}
|
|
14282
14294
|
});
|
|
14283
14295
|
}
|
|
@@ -14285,6 +14297,7 @@ var init_rollback = __esm(() => {
|
|
|
14285
14297
|
init_src3();
|
|
14286
14298
|
init_api_client();
|
|
14287
14299
|
init_config_store();
|
|
14300
|
+
init_handle_api_error();
|
|
14288
14301
|
});
|
|
14289
14302
|
|
|
14290
14303
|
// src/commands/openapi.ts
|
|
@@ -14306,9 +14319,7 @@ function registerOpenApiCommand(program2) {
|
|
|
14306
14319
|
const spec = await client.get(`/api/v1/projects/${opts.project}/openapi/_dura/openapi.json`, { projectId: opts.project });
|
|
14307
14320
|
output.success(spec);
|
|
14308
14321
|
} catch (err) {
|
|
14309
|
-
|
|
14310
|
-
output.error("OPENAPI_FAILED", err.message);
|
|
14311
|
-
}
|
|
14322
|
+
reportApiError(output, err, "OPENAPI_FAILED");
|
|
14312
14323
|
}
|
|
14313
14324
|
});
|
|
14314
14325
|
}
|
|
@@ -14316,6 +14327,7 @@ var init_openapi = __esm(() => {
|
|
|
14316
14327
|
init_src3();
|
|
14317
14328
|
init_api_client();
|
|
14318
14329
|
init_config_store();
|
|
14330
|
+
init_handle_api_error();
|
|
14319
14331
|
});
|
|
14320
14332
|
|
|
14321
14333
|
// src/commands/logs.ts
|
|
@@ -14579,11 +14591,7 @@ Error: ${name}
|
|
|
14579
14591
|
]));
|
|
14580
14592
|
}
|
|
14581
14593
|
} 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
|
-
}
|
|
14594
|
+
reportApiError(output, err, "LOGS_FAILED");
|
|
14587
14595
|
}
|
|
14588
14596
|
});
|
|
14589
14597
|
}
|
|
@@ -14592,6 +14600,7 @@ var init_logs = __esm(() => {
|
|
|
14592
14600
|
init_api_client();
|
|
14593
14601
|
init_config_store();
|
|
14594
14602
|
init_project_id();
|
|
14603
|
+
init_handle_api_error();
|
|
14595
14604
|
});
|
|
14596
14605
|
|
|
14597
14606
|
// src/commands/run.ts
|
|
@@ -14625,11 +14634,7 @@ function registerRunCommand(program2) {
|
|
|
14625
14634
|
});
|
|
14626
14635
|
output.success(result);
|
|
14627
14636
|
} 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
|
-
}
|
|
14637
|
+
reportApiError(output, err, "RUN_FAILED");
|
|
14633
14638
|
}
|
|
14634
14639
|
});
|
|
14635
14640
|
}
|
|
@@ -14637,6 +14642,7 @@ var init_run = __esm(() => {
|
|
|
14637
14642
|
init_src3();
|
|
14638
14643
|
init_api_client();
|
|
14639
14644
|
init_config_store();
|
|
14645
|
+
init_handle_api_error();
|
|
14640
14646
|
});
|
|
14641
14647
|
|
|
14642
14648
|
// src/commands/schedule.ts
|
|
@@ -14672,11 +14678,7 @@ function registerScheduleCommand(program2) {
|
|
|
14672
14678
|
});
|
|
14673
14679
|
output.success(result);
|
|
14674
14680
|
} 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
|
-
}
|
|
14681
|
+
reportApiError(output, err, "SCHEDULE_FAILED");
|
|
14680
14682
|
}
|
|
14681
14683
|
});
|
|
14682
14684
|
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 +14697,7 @@ function registerScheduleCommand(program2) {
|
|
|
14695
14697
|
const result = await auth.client.get(`/api/v1/projects/${projectId}/schedules`);
|
|
14696
14698
|
output.success(result);
|
|
14697
14699
|
} 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
|
-
}
|
|
14700
|
+
reportApiError(output, err, "SCHEDULE_LIST_FAILED");
|
|
14703
14701
|
}
|
|
14704
14702
|
});
|
|
14705
14703
|
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 +14720,7 @@ function registerScheduleCommand(program2) {
|
|
|
14722
14720
|
const result = await auth.client.delete(`/api/v1/projects/${projectId}/schedules/${scheduleId}`);
|
|
14723
14721
|
output.success(result);
|
|
14724
14722
|
} 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
|
-
}
|
|
14723
|
+
reportApiError(output, err, "SCHEDULE_REMOVE_FAILED");
|
|
14730
14724
|
}
|
|
14731
14725
|
});
|
|
14732
14726
|
}
|
|
@@ -14735,6 +14729,7 @@ var init_schedule = __esm(() => {
|
|
|
14735
14729
|
init_api_client();
|
|
14736
14730
|
init_config_store();
|
|
14737
14731
|
init_project_id();
|
|
14732
|
+
init_handle_api_error();
|
|
14738
14733
|
});
|
|
14739
14734
|
|
|
14740
14735
|
// src/lib/dev-trust.ts
|
|
@@ -16582,9 +16577,7 @@ Add this TXT record to your DNS:
|
|
|
16582
16577
|
Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
16583
16578
|
}
|
|
16584
16579
|
} catch (err) {
|
|
16585
|
-
|
|
16586
|
-
output.error("DOMAIN_ADD_FAILED", err.message);
|
|
16587
|
-
}
|
|
16580
|
+
reportApiError(output, err, "DOMAIN_ADD_FAILED");
|
|
16588
16581
|
}
|
|
16589
16582
|
});
|
|
16590
16583
|
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 +16595,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16602
16595
|
d.createdAt
|
|
16603
16596
|
]));
|
|
16604
16597
|
} catch (err) {
|
|
16605
|
-
|
|
16606
|
-
output.error("DOMAIN_LIST_FAILED", err.message);
|
|
16607
|
-
}
|
|
16598
|
+
reportApiError(output, err, "DOMAIN_LIST_FAILED");
|
|
16608
16599
|
}
|
|
16609
16600
|
});
|
|
16610
16601
|
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 +16612,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16621
16612
|
await client.delete(`/api/v1/projects/${projectId}/domains/${domainId}`);
|
|
16622
16613
|
output.success({ deleted: true, domainId });
|
|
16623
16614
|
} catch (err) {
|
|
16624
|
-
|
|
16625
|
-
output.error("DOMAIN_REMOVE_FAILED", err.message);
|
|
16626
|
-
}
|
|
16615
|
+
reportApiError(output, err, "DOMAIN_REMOVE_FAILED");
|
|
16627
16616
|
}
|
|
16628
16617
|
});
|
|
16629
16618
|
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 +16625,7 @@ Then run: dura domains verify ${result.id} --project ${projectId}`);
|
|
|
16636
16625
|
const result = await client.post(`/api/v1/projects/${projectId}/domains/${domainId}/verify`, {});
|
|
16637
16626
|
output.success(result);
|
|
16638
16627
|
} catch (err) {
|
|
16639
|
-
|
|
16640
|
-
output.error("DOMAIN_VERIFY_FAILED", err.message);
|
|
16641
|
-
}
|
|
16628
|
+
reportApiError(output, err, "DOMAIN_VERIFY_FAILED");
|
|
16642
16629
|
}
|
|
16643
16630
|
});
|
|
16644
16631
|
}
|
|
@@ -16647,6 +16634,7 @@ var init_domains = __esm(() => {
|
|
|
16647
16634
|
init_api_client();
|
|
16648
16635
|
init_config_store();
|
|
16649
16636
|
init_project_id();
|
|
16637
|
+
init_handle_api_error();
|
|
16650
16638
|
});
|
|
16651
16639
|
|
|
16652
16640
|
// src/commands/endpoint-keys.ts
|
|
@@ -16686,9 +16674,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16686
16674
|
output.warn("Save the key now — it will not be shown again.");
|
|
16687
16675
|
}
|
|
16688
16676
|
} catch (err) {
|
|
16689
|
-
|
|
16690
|
-
output.error("ENDPOINT_KEY_CREATE_FAILED", err.message);
|
|
16691
|
-
}
|
|
16677
|
+
reportApiError(output, err, "ENDPOINT_KEY_CREATE_FAILED");
|
|
16692
16678
|
}
|
|
16693
16679
|
});
|
|
16694
16680
|
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 +16694,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16708
16694
|
k.createdAt
|
|
16709
16695
|
]));
|
|
16710
16696
|
} catch (err) {
|
|
16711
|
-
|
|
16712
|
-
output.error("ENDPOINT_KEY_LIST_FAILED", err.message);
|
|
16713
|
-
}
|
|
16697
|
+
reportApiError(output, err, "ENDPOINT_KEY_LIST_FAILED");
|
|
16714
16698
|
}
|
|
16715
16699
|
});
|
|
16716
16700
|
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 +16711,7 @@ function registerEndpointKeysCommand(program2) {
|
|
|
16727
16711
|
await client.post(`/api/v1/projects/${projectId}/endpoint-keys/${keyId}/revoke`, {});
|
|
16728
16712
|
output.success({ revoked: true, keyId });
|
|
16729
16713
|
} catch (err) {
|
|
16730
|
-
|
|
16731
|
-
output.error("ENDPOINT_KEY_REVOKE_FAILED", err.message);
|
|
16732
|
-
}
|
|
16714
|
+
reportApiError(output, err, "ENDPOINT_KEY_REVOKE_FAILED");
|
|
16733
16715
|
}
|
|
16734
16716
|
});
|
|
16735
16717
|
}
|
|
@@ -16738,6 +16720,81 @@ var init_endpoint_keys2 = __esm(() => {
|
|
|
16738
16720
|
init_api_client();
|
|
16739
16721
|
init_config_store();
|
|
16740
16722
|
init_project_id();
|
|
16723
|
+
init_handle_api_error();
|
|
16724
|
+
});
|
|
16725
|
+
|
|
16726
|
+
// src/commands/events.ts
|
|
16727
|
+
var exports_events = {};
|
|
16728
|
+
__export(exports_events, {
|
|
16729
|
+
resolvePayload: () => resolvePayload,
|
|
16730
|
+
registerEventsCommand: () => registerEventsCommand
|
|
16731
|
+
});
|
|
16732
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
16733
|
+
function resolvePayload(opts) {
|
|
16734
|
+
if (opts.payload !== undefined && opts.payloadFile !== undefined) {
|
|
16735
|
+
throw new Error("Use either --payload or --payload-file, not both");
|
|
16736
|
+
}
|
|
16737
|
+
if (opts.payload === undefined && opts.payloadFile === undefined) {
|
|
16738
|
+
throw new Error("--payload or --payload-file is required");
|
|
16739
|
+
}
|
|
16740
|
+
const raw = opts.payload !== undefined ? opts.payload : readFileSync8(opts.payloadFile, "utf-8");
|
|
16741
|
+
try {
|
|
16742
|
+
return JSON.parse(raw);
|
|
16743
|
+
} catch (err) {
|
|
16744
|
+
throw new Error(`Invalid JSON in payload: ${err.message}`);
|
|
16745
|
+
}
|
|
16746
|
+
}
|
|
16747
|
+
function registerEventsCommand(program2) {
|
|
16748
|
+
const events = program2.command("events").description("Emit and inspect project events");
|
|
16749
|
+
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) => {
|
|
16750
|
+
const output = getOutput(cmd);
|
|
16751
|
+
let payload;
|
|
16752
|
+
try {
|
|
16753
|
+
payload = resolvePayload(opts);
|
|
16754
|
+
} catch (err) {
|
|
16755
|
+
output.error("INVALID_PAYLOAD", err.message);
|
|
16756
|
+
return;
|
|
16757
|
+
}
|
|
16758
|
+
const projectId = resolveProjectId({ project: opts.project });
|
|
16759
|
+
if (!projectId) {
|
|
16760
|
+
output.error("PROJECT_REQUIRED", "No project ID. Use --project or run this command inside a dura.json project.");
|
|
16761
|
+
return;
|
|
16762
|
+
}
|
|
16763
|
+
const token = opts.token || getAuthToken();
|
|
16764
|
+
if (!token) {
|
|
16765
|
+
output.error("AUTH_REQUIRED", "Not logged in", "Run: dura login");
|
|
16766
|
+
return;
|
|
16767
|
+
}
|
|
16768
|
+
const apiUrl = opts.apiUrl || getApiUrl();
|
|
16769
|
+
const client = new ApiClient(apiUrl, token);
|
|
16770
|
+
try {
|
|
16771
|
+
const result = await client.post(`/api/v1/projects/${projectId}/events`, { source, payload });
|
|
16772
|
+
if (output.isJson()) {
|
|
16773
|
+
output.success(result);
|
|
16774
|
+
return;
|
|
16775
|
+
}
|
|
16776
|
+
if (result.jobs.length === 0) {
|
|
16777
|
+
process.stdout.write(`Event "${source}" emitted — no subscribers matched.
|
|
16778
|
+
`);
|
|
16779
|
+
return;
|
|
16780
|
+
}
|
|
16781
|
+
process.stdout.write(`Event "${source}" emitted — enqueued ${result.jobs.length} execution(s):
|
|
16782
|
+
`);
|
|
16783
|
+
for (const job of result.jobs) {
|
|
16784
|
+
process.stdout.write(` • ${job.automationName} → execution ${job.trigger.executionId}
|
|
16785
|
+
`);
|
|
16786
|
+
}
|
|
16787
|
+
} catch (err) {
|
|
16788
|
+
const e = err;
|
|
16789
|
+
output.error(e.code ?? "EMIT_FAILED", e.message);
|
|
16790
|
+
}
|
|
16791
|
+
});
|
|
16792
|
+
}
|
|
16793
|
+
var init_events = __esm(() => {
|
|
16794
|
+
init_src3();
|
|
16795
|
+
init_api_client();
|
|
16796
|
+
init_config_store();
|
|
16797
|
+
init_project_id();
|
|
16741
16798
|
});
|
|
16742
16799
|
|
|
16743
16800
|
// src/commands/usage.ts
|
|
@@ -16824,11 +16881,7 @@ function registerUsageCommand(program2) {
|
|
|
16824
16881
|
browserTime: formatMs(summary.totals.totalBrowserSessionMs)
|
|
16825
16882
|
});
|
|
16826
16883
|
} 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
|
-
}
|
|
16884
|
+
reportApiError(output, err, "USAGE_QUERY_FAILED");
|
|
16832
16885
|
}
|
|
16833
16886
|
});
|
|
16834
16887
|
}
|
|
@@ -16836,6 +16889,7 @@ var init_usage = __esm(() => {
|
|
|
16836
16889
|
init_src3();
|
|
16837
16890
|
init_api_client();
|
|
16838
16891
|
init_config_store();
|
|
16892
|
+
init_handle_api_error();
|
|
16839
16893
|
});
|
|
16840
16894
|
|
|
16841
16895
|
// src/commands/marketplace.ts
|
|
@@ -16873,11 +16927,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16873
16927
|
status: adapter.status
|
|
16874
16928
|
});
|
|
16875
16929
|
} 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
|
-
}
|
|
16930
|
+
reportApiError(output, err, "PUBLISH_FAILED");
|
|
16881
16931
|
}
|
|
16882
16932
|
});
|
|
16883
16933
|
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 +16948,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16898
16948
|
version: install.adapterVersion
|
|
16899
16949
|
});
|
|
16900
16950
|
} 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
|
-
}
|
|
16951
|
+
reportApiError(output, err, "INSTALL_FAILED");
|
|
16906
16952
|
}
|
|
16907
16953
|
});
|
|
16908
16954
|
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 +16984,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16938
16984
|
a.status
|
|
16939
16985
|
]));
|
|
16940
16986
|
} 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
|
-
}
|
|
16987
|
+
reportApiError(output, err, "LIST_FAILED");
|
|
16946
16988
|
}
|
|
16947
16989
|
});
|
|
16948
16990
|
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 +17004,7 @@ function registerMarketplaceCommand(program2) {
|
|
|
16962
17004
|
await client.post(`/api/v1/projects/${opts.project}/adapters/uninstall`, { adapterId: opts.adapter });
|
|
16963
17005
|
output.success({ uninstalled: true, adapterId: opts.adapter });
|
|
16964
17006
|
} 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
|
-
}
|
|
17007
|
+
reportApiError(output, err, "UNINSTALL_FAILED");
|
|
16970
17008
|
}
|
|
16971
17009
|
});
|
|
16972
17010
|
}
|
|
@@ -16974,6 +17012,7 @@ var init_marketplace2 = __esm(() => {
|
|
|
16974
17012
|
init_src3();
|
|
16975
17013
|
init_api_client();
|
|
16976
17014
|
init_config_store();
|
|
17015
|
+
init_handle_api_error();
|
|
16977
17016
|
});
|
|
16978
17017
|
|
|
16979
17018
|
// src/commands/export.ts
|
|
@@ -16985,7 +17024,7 @@ __export(exports_export, {
|
|
|
16985
17024
|
});
|
|
16986
17025
|
import {
|
|
16987
17026
|
existsSync as existsSync10,
|
|
16988
|
-
readFileSync as
|
|
17027
|
+
readFileSync as readFileSync9,
|
|
16989
17028
|
readdirSync as readdirSync3,
|
|
16990
17029
|
statSync,
|
|
16991
17030
|
writeFileSync as writeFileSync8
|
|
@@ -17005,7 +17044,7 @@ function collectExportFiles(baseDir, currentDir) {
|
|
|
17005
17044
|
}
|
|
17006
17045
|
} else if (stat.isFile()) {
|
|
17007
17046
|
if (!EXCLUDED_FILES.has(item)) {
|
|
17008
|
-
const content =
|
|
17047
|
+
const content = readFileSync9(fullPath, "utf-8");
|
|
17009
17048
|
entries.push({ relativePath: relPath, content });
|
|
17010
17049
|
}
|
|
17011
17050
|
}
|
|
@@ -17036,7 +17075,7 @@ function registerExportCommand(program2) {
|
|
|
17036
17075
|
}
|
|
17037
17076
|
let projectName;
|
|
17038
17077
|
try {
|
|
17039
|
-
const manifestContent =
|
|
17078
|
+
const manifestContent = readFileSync9(manifestPath, "utf-8");
|
|
17040
17079
|
const manifest = JSON.parse(manifestContent);
|
|
17041
17080
|
projectName = manifest.name ?? "unnamed-project";
|
|
17042
17081
|
} catch {
|
|
@@ -17124,11 +17163,7 @@ function registerReplayCommand(program2) {
|
|
|
17124
17163
|
const result = await client.post(`/api/v1/projects/${projectId}/executions/${executionId}/replay`, { overrides });
|
|
17125
17164
|
output.success(result);
|
|
17126
17165
|
} 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
|
-
}
|
|
17166
|
+
reportApiError(output, err, "REPLAY_FAILED");
|
|
17132
17167
|
}
|
|
17133
17168
|
});
|
|
17134
17169
|
}
|
|
@@ -17165,11 +17200,7 @@ function registerReplaysCommand(program2) {
|
|
|
17165
17200
|
r.replayOf ?? "-"
|
|
17166
17201
|
]));
|
|
17167
17202
|
} 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
|
-
}
|
|
17203
|
+
reportApiError(output, err, "REPLAYS_FAILED");
|
|
17173
17204
|
}
|
|
17174
17205
|
});
|
|
17175
17206
|
}
|
|
@@ -17178,6 +17209,7 @@ var init_replay = __esm(() => {
|
|
|
17178
17209
|
init_api_client();
|
|
17179
17210
|
init_config_store();
|
|
17180
17211
|
init_project_id();
|
|
17212
|
+
init_handle_api_error();
|
|
17181
17213
|
});
|
|
17182
17214
|
|
|
17183
17215
|
// src/commands/kv.ts
|
|
@@ -17224,11 +17256,7 @@ function registerKvCommand(program2) {
|
|
|
17224
17256
|
}
|
|
17225
17257
|
output.table(["Key"], keys.map((k) => [k]));
|
|
17226
17258
|
} 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
|
-
}
|
|
17259
|
+
reportApiError(output, err, "KV_LIST_FAILED");
|
|
17232
17260
|
}
|
|
17233
17261
|
});
|
|
17234
17262
|
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 +17269,7 @@ function registerKvCommand(program2) {
|
|
|
17241
17269
|
const result = await client.get(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`);
|
|
17242
17270
|
output.success(result);
|
|
17243
17271
|
} 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
|
-
}
|
|
17272
|
+
reportApiError(output, err, "KV_GET_FAILED");
|
|
17249
17273
|
}
|
|
17250
17274
|
});
|
|
17251
17275
|
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 +17292,7 @@ function registerKvCommand(program2) {
|
|
|
17268
17292
|
const result = await client.put(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`, body);
|
|
17269
17293
|
output.success(result);
|
|
17270
17294
|
} 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
|
-
}
|
|
17295
|
+
reportApiError(output, err, "KV_SET_FAILED");
|
|
17276
17296
|
}
|
|
17277
17297
|
});
|
|
17278
17298
|
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 +17309,7 @@ function registerKvCommand(program2) {
|
|
|
17289
17309
|
await client.delete(`/api/v1/projects/${projectId}/kv/${encodeURIComponent(key)}`);
|
|
17290
17310
|
output.success({ deleted: true, key });
|
|
17291
17311
|
} 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
|
-
}
|
|
17312
|
+
reportApiError(output, err, "KV_DELETE_FAILED");
|
|
17297
17313
|
}
|
|
17298
17314
|
});
|
|
17299
17315
|
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 +17326,7 @@ function registerKvCommand(program2) {
|
|
|
17310
17326
|
await client.delete(`/api/v1/projects/${projectId}/kv`);
|
|
17311
17327
|
output.success({ flushed: true });
|
|
17312
17328
|
} 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
|
-
}
|
|
17329
|
+
reportApiError(output, err, "KV_FLUSH_FAILED");
|
|
17318
17330
|
}
|
|
17319
17331
|
});
|
|
17320
17332
|
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 +17339,7 @@ function registerKvCommand(program2) {
|
|
|
17327
17339
|
const stats = await client.get(`/api/v1/projects/${projectId}/kv/stats`);
|
|
17328
17340
|
output.success(stats);
|
|
17329
17341
|
} 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
|
-
}
|
|
17342
|
+
reportApiError(output, err, "KV_STATS_FAILED");
|
|
17335
17343
|
}
|
|
17336
17344
|
});
|
|
17337
17345
|
}
|
|
@@ -17340,6 +17348,7 @@ var init_kv2 = __esm(() => {
|
|
|
17340
17348
|
init_api_client();
|
|
17341
17349
|
init_config_store();
|
|
17342
17350
|
init_project_id();
|
|
17351
|
+
init_handle_api_error();
|
|
17343
17352
|
});
|
|
17344
17353
|
|
|
17345
17354
|
// src/commands/webhook.ts
|
|
@@ -17406,9 +17415,7 @@ Webhook relay "${result.name}" created.
|
|
|
17406
17415
|
` + `ID: ${result.id}`);
|
|
17407
17416
|
}
|
|
17408
17417
|
} catch (err) {
|
|
17409
|
-
|
|
17410
|
-
output.error("WEBHOOK_CREATE_FAILED", err.message);
|
|
17411
|
-
}
|
|
17418
|
+
reportApiError(output, err, "WEBHOOK_CREATE_FAILED");
|
|
17412
17419
|
}
|
|
17413
17420
|
});
|
|
17414
17421
|
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 +17438,7 @@ Webhook relay "${result.name}" created.
|
|
|
17431
17438
|
]));
|
|
17432
17439
|
}
|
|
17433
17440
|
} catch (err) {
|
|
17434
|
-
|
|
17435
|
-
output.error("WEBHOOK_LIST_FAILED", err.message);
|
|
17436
|
-
}
|
|
17441
|
+
reportApiError(output, err, "WEBHOOK_LIST_FAILED");
|
|
17437
17442
|
}
|
|
17438
17443
|
});
|
|
17439
17444
|
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 +17451,7 @@ Webhook relay "${result.name}" created.
|
|
|
17446
17451
|
const result = await client.get(`${webhookBase(opts.project)}/${nameOrId}`);
|
|
17447
17452
|
output.success(result);
|
|
17448
17453
|
} catch (err) {
|
|
17449
|
-
|
|
17450
|
-
output.error("WEBHOOK_SHOW_FAILED", err.message);
|
|
17451
|
-
}
|
|
17454
|
+
reportApiError(output, err, "WEBHOOK_SHOW_FAILED");
|
|
17452
17455
|
}
|
|
17453
17456
|
});
|
|
17454
17457
|
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 +17485,7 @@ Webhook relay "${result.name}" created.
|
|
|
17482
17485
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, patch);
|
|
17483
17486
|
output.success(result);
|
|
17484
17487
|
} catch (err) {
|
|
17485
|
-
|
|
17486
|
-
output.error("WEBHOOK_UPDATE_FAILED", err.message);
|
|
17487
|
-
}
|
|
17488
|
+
reportApiError(output, err, "WEBHOOK_UPDATE_FAILED");
|
|
17488
17489
|
}
|
|
17489
17490
|
});
|
|
17490
17491
|
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 +17502,7 @@ Webhook relay "${result.name}" created.
|
|
|
17501
17502
|
await client.delete(`${webhookBase(opts.project)}/${nameOrId}`);
|
|
17502
17503
|
output.success({ deleted: true, nameOrId });
|
|
17503
17504
|
} catch (err) {
|
|
17504
|
-
|
|
17505
|
-
output.error("WEBHOOK_DELETE_FAILED", err.message);
|
|
17506
|
-
}
|
|
17505
|
+
reportApiError(output, err, "WEBHOOK_DELETE_FAILED");
|
|
17507
17506
|
}
|
|
17508
17507
|
});
|
|
17509
17508
|
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 +17515,7 @@ Webhook relay "${result.name}" created.
|
|
|
17516
17515
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, { enabled: true });
|
|
17517
17516
|
output.success(result);
|
|
17518
17517
|
} catch (err) {
|
|
17519
|
-
|
|
17520
|
-
output.error("WEBHOOK_ENABLE_FAILED", err.message);
|
|
17521
|
-
}
|
|
17518
|
+
reportApiError(output, err, "WEBHOOK_ENABLE_FAILED");
|
|
17522
17519
|
}
|
|
17523
17520
|
});
|
|
17524
17521
|
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 +17528,7 @@ Webhook relay "${result.name}" created.
|
|
|
17531
17528
|
const result = await client.patch(`${webhookBase(opts.project)}/${nameOrId}`, { enabled: false });
|
|
17532
17529
|
output.success(result);
|
|
17533
17530
|
} catch (err) {
|
|
17534
|
-
|
|
17535
|
-
output.error("WEBHOOK_DISABLE_FAILED", err.message);
|
|
17536
|
-
}
|
|
17531
|
+
reportApiError(output, err, "WEBHOOK_DISABLE_FAILED");
|
|
17537
17532
|
}
|
|
17538
17533
|
});
|
|
17539
17534
|
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 +17565,7 @@ Webhook relay "${result.name}" created.
|
|
|
17570
17565
|
}
|
|
17571
17566
|
}
|
|
17572
17567
|
} catch (err) {
|
|
17573
|
-
|
|
17574
|
-
output.error("WEBHOOK_TEST_FAILED", err.message);
|
|
17575
|
-
}
|
|
17568
|
+
reportApiError(output, err, "WEBHOOK_TEST_FAILED");
|
|
17576
17569
|
}
|
|
17577
17570
|
});
|
|
17578
17571
|
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 +17598,7 @@ Webhook relay "${result.name}" created.
|
|
|
17605
17598
|
]));
|
|
17606
17599
|
}
|
|
17607
17600
|
} catch (err) {
|
|
17608
|
-
|
|
17609
|
-
output.error("WEBHOOK_DELIVERIES_FAILED", err.message);
|
|
17610
|
-
}
|
|
17601
|
+
reportApiError(output, err, "WEBHOOK_DELIVERIES_FAILED");
|
|
17611
17602
|
}
|
|
17612
17603
|
});
|
|
17613
17604
|
}
|
|
@@ -17615,6 +17606,7 @@ var init_webhook = __esm(() => {
|
|
|
17615
17606
|
init_src3();
|
|
17616
17607
|
init_api_client();
|
|
17617
17608
|
init_config_store();
|
|
17609
|
+
init_handle_api_error();
|
|
17618
17610
|
});
|
|
17619
17611
|
|
|
17620
17612
|
// src/commands/template.ts
|
|
@@ -17656,11 +17648,7 @@ function registerTemplateCommand(program2) {
|
|
|
17656
17648
|
String(t.starCount)
|
|
17657
17649
|
]));
|
|
17658
17650
|
} 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
|
-
}
|
|
17651
|
+
reportApiError(output, err, "LIST_FAILED");
|
|
17664
17652
|
}
|
|
17665
17653
|
});
|
|
17666
17654
|
const template = program2.command("template").description("Manage project templates");
|
|
@@ -17689,11 +17677,7 @@ function registerTemplateCommand(program2) {
|
|
|
17689
17677
|
}
|
|
17690
17678
|
output.success({ slug: t.slug, bundleRef: t.bundleRef });
|
|
17691
17679
|
} 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
|
-
}
|
|
17680
|
+
reportApiError(output, err, "SHOW_FAILED");
|
|
17697
17681
|
}
|
|
17698
17682
|
});
|
|
17699
17683
|
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 +17709,7 @@ function registerTemplateCommand(program2) {
|
|
|
17725
17709
|
status: t.status
|
|
17726
17710
|
});
|
|
17727
17711
|
} 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
|
-
}
|
|
17712
|
+
reportApiError(output, err, "PUBLISH_FAILED");
|
|
17733
17713
|
}
|
|
17734
17714
|
});
|
|
17735
17715
|
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 +17745,7 @@ Set required secrets: ${result.requiredSecrets.join(", ")}`);
|
|
|
17765
17745
|
output.info("Run: dura secrets set <name> <value>");
|
|
17766
17746
|
}
|
|
17767
17747
|
} 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
|
-
}
|
|
17748
|
+
reportApiError(output, err, "FORK_FAILED");
|
|
17773
17749
|
}
|
|
17774
17750
|
});
|
|
17775
17751
|
}
|
|
@@ -17777,6 +17753,7 @@ var init_template = __esm(() => {
|
|
|
17777
17753
|
init_src3();
|
|
17778
17754
|
init_api_client();
|
|
17779
17755
|
init_config_store();
|
|
17756
|
+
init_handle_api_error();
|
|
17780
17757
|
});
|
|
17781
17758
|
|
|
17782
17759
|
// src/commands/deployments.ts
|
|
@@ -17818,11 +17795,7 @@ function registerDeploymentsCommand(program2) {
|
|
|
17818
17795
|
}
|
|
17819
17796
|
output.table(["ID", "Status", "Created At"], deploymentList.map((d) => [d.id, d.status, d.createdAt]));
|
|
17820
17797
|
} 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
|
-
}
|
|
17798
|
+
reportApiError(output, err, "DEPLOYMENTS_LIST_FAILED");
|
|
17826
17799
|
}
|
|
17827
17800
|
});
|
|
17828
17801
|
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 +17808,7 @@ function registerDeploymentsCommand(program2) {
|
|
|
17835
17808
|
const deployment = await client.get(`/api/v1/projects/${projectId}/deployments/${opts.id}`);
|
|
17836
17809
|
output.success(deployment);
|
|
17837
17810
|
} 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
|
-
}
|
|
17811
|
+
reportApiError(output, err, "DEPLOYMENTS_GET_FAILED");
|
|
17843
17812
|
}
|
|
17844
17813
|
});
|
|
17845
17814
|
}
|
|
@@ -17848,6 +17817,7 @@ var init_deployments2 = __esm(() => {
|
|
|
17848
17817
|
init_api_client();
|
|
17849
17818
|
init_config_store();
|
|
17850
17819
|
init_project_id();
|
|
17820
|
+
init_handle_api_error();
|
|
17851
17821
|
});
|
|
17852
17822
|
|
|
17853
17823
|
// src/commands/diagnose.ts
|
|
@@ -17957,11 +17927,7 @@ Analyzing execution ${targetExecutionId}...`);
|
|
|
17957
17927
|
output.info(formatDiagnosisHuman(diagnosis));
|
|
17958
17928
|
}
|
|
17959
17929
|
} 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
|
-
}
|
|
17930
|
+
reportApiError(output, err, "DIAGNOSE_FAILED");
|
|
17965
17931
|
}
|
|
17966
17932
|
});
|
|
17967
17933
|
}
|
|
@@ -17970,6 +17936,7 @@ var init_diagnose = __esm(() => {
|
|
|
17970
17936
|
init_api_client();
|
|
17971
17937
|
init_config_store();
|
|
17972
17938
|
init_project_id();
|
|
17939
|
+
init_handle_api_error();
|
|
17973
17940
|
});
|
|
17974
17941
|
|
|
17975
17942
|
// src/commands/create.ts
|
|
@@ -17982,7 +17949,7 @@ import {
|
|
|
17982
17949
|
existsSync as existsSync11,
|
|
17983
17950
|
mkdirSync as mkdirSync6,
|
|
17984
17951
|
writeFileSync as writeFileSync9,
|
|
17985
|
-
readFileSync as
|
|
17952
|
+
readFileSync as readFileSync10,
|
|
17986
17953
|
readdirSync as readdirSync4
|
|
17987
17954
|
} from "node:fs";
|
|
17988
17955
|
import { join as join12, resolve as resolve5, dirname as dirname2 } from "node:path";
|
|
@@ -18055,11 +18022,7 @@ function registerCreateCommand(program2) {
|
|
|
18055
18022
|
try {
|
|
18056
18023
|
generateResult = await client.post(`/api/v1/projects/${projectId}/ai/generate`, { description });
|
|
18057
18024
|
} 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
|
-
}
|
|
18025
|
+
reportApiError(output, err, "GENERATE_FAILED");
|
|
18063
18026
|
return;
|
|
18064
18027
|
}
|
|
18065
18028
|
output.info(`Generated ${generateResult.files.length} file(s): ${generateResult.files.map((f) => f.path).join(", ")}`);
|
|
@@ -18113,7 +18076,7 @@ function registerAddCommand(program2) {
|
|
|
18113
18076
|
const existingRoutes = getExistingRoutes(projectDir);
|
|
18114
18077
|
let projectConfig = {};
|
|
18115
18078
|
try {
|
|
18116
|
-
projectConfig = JSON.parse(
|
|
18079
|
+
projectConfig = JSON.parse(readFileSync10(duraJsonPath, "utf-8"));
|
|
18117
18080
|
} catch {}
|
|
18118
18081
|
const apiUrl = getApiUrl();
|
|
18119
18082
|
const client = new ApiClient(apiUrl, token);
|
|
@@ -18128,11 +18091,7 @@ function registerAddCommand(program2) {
|
|
|
18128
18091
|
}
|
|
18129
18092
|
});
|
|
18130
18093
|
} 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
|
-
}
|
|
18094
|
+
reportApiError(output, err, "GENERATE_FAILED");
|
|
18136
18095
|
return;
|
|
18137
18096
|
}
|
|
18138
18097
|
output.info(`Generated ${generateResult.files.length} file(s): ${generateResult.files.map((f) => f.path).join(", ")}`);
|
|
@@ -18163,6 +18122,7 @@ var init_create = __esm(() => {
|
|
|
18163
18122
|
init_src3();
|
|
18164
18123
|
init_api_client();
|
|
18165
18124
|
init_config_store();
|
|
18125
|
+
init_handle_api_error();
|
|
18166
18126
|
});
|
|
18167
18127
|
|
|
18168
18128
|
// src/commands/workflow.ts
|
|
@@ -18207,11 +18167,7 @@ function registerWorkflowsCommand(program2) {
|
|
|
18207
18167
|
d.createdAt
|
|
18208
18168
|
]));
|
|
18209
18169
|
} 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
|
-
}
|
|
18170
|
+
reportApiError(output, err, "WORKFLOWS_LIST_FAILED");
|
|
18215
18171
|
}
|
|
18216
18172
|
});
|
|
18217
18173
|
}
|
|
@@ -18240,11 +18196,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18240
18196
|
}
|
|
18241
18197
|
output.info(`Workflow run started: ${result.runId}`);
|
|
18242
18198
|
} 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
|
-
}
|
|
18199
|
+
reportApiError(output, err, "WORKFLOW_RUN_FAILED");
|
|
18248
18200
|
}
|
|
18249
18201
|
});
|
|
18250
18202
|
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 +18220,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18268
18220
|
}
|
|
18269
18221
|
output.table(["ID", "Status", "Trigger", "Created"], runs.map((r) => [r.id, r.status, r.triggerType, r.createdAt]));
|
|
18270
18222
|
} 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
|
-
}
|
|
18223
|
+
reportApiError(output, err, "WORKFLOW_RUNS_FAILED");
|
|
18276
18224
|
}
|
|
18277
18225
|
});
|
|
18278
18226
|
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 +18237,7 @@ function registerWorkflowCommand(program2) {
|
|
|
18289
18237
|
await client.post(`/api/v1/projects/${opts.project}/workflow-runs/${encodeURIComponent(runId)}/cancel`, {});
|
|
18290
18238
|
output.info(`Workflow run ${runId} cancelled.`);
|
|
18291
18239
|
} 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
|
-
}
|
|
18240
|
+
reportApiError(output, err, "WORKFLOW_CANCEL_FAILED");
|
|
18297
18241
|
}
|
|
18298
18242
|
});
|
|
18299
18243
|
}
|
|
@@ -18325,11 +18269,7 @@ function registerApprovalsCommand(program2) {
|
|
|
18325
18269
|
a.createdAt
|
|
18326
18270
|
]));
|
|
18327
18271
|
} 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
|
-
}
|
|
18272
|
+
reportApiError(output, err, "APPROVALS_LIST_FAILED");
|
|
18333
18273
|
}
|
|
18334
18274
|
});
|
|
18335
18275
|
}
|
|
@@ -18344,11 +18284,7 @@ function registerApproveCommand(program2) {
|
|
|
18344
18284
|
await client.post(`/api/v1/projects/${opts.project}/approvals/${encodeURIComponent(approvalId)}/approve`, { decidedBy: opts.decidedBy });
|
|
18345
18285
|
output.info(`Approval ${approvalId} approved.`);
|
|
18346
18286
|
} 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
|
-
}
|
|
18287
|
+
reportApiError(output, err, "APPROVE_FAILED");
|
|
18352
18288
|
}
|
|
18353
18289
|
});
|
|
18354
18290
|
}
|
|
@@ -18363,11 +18299,7 @@ function registerRejectCommand(program2) {
|
|
|
18363
18299
|
await client.post(`/api/v1/projects/${opts.project}/approvals/${encodeURIComponent(approvalId)}/reject`, { decidedBy: opts.decidedBy, reason: opts.reason });
|
|
18364
18300
|
output.info(`Approval ${approvalId} rejected.`);
|
|
18365
18301
|
} 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
|
-
}
|
|
18302
|
+
reportApiError(output, err, "REJECT_FAILED");
|
|
18371
18303
|
}
|
|
18372
18304
|
});
|
|
18373
18305
|
}
|
|
@@ -18375,6 +18307,7 @@ var init_workflow = __esm(() => {
|
|
|
18375
18307
|
init_src3();
|
|
18376
18308
|
init_api_client();
|
|
18377
18309
|
init_config_store();
|
|
18310
|
+
init_handle_api_error();
|
|
18378
18311
|
});
|
|
18379
18312
|
|
|
18380
18313
|
// src/commands/env.ts
|
|
@@ -18416,11 +18349,7 @@ function registerEnvCommand(program2) {
|
|
|
18416
18349
|
});
|
|
18417
18350
|
output.success(env2);
|
|
18418
18351
|
} 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
|
-
}
|
|
18352
|
+
reportApiError(output, err, "ENV_CREATE_FAILED");
|
|
18424
18353
|
}
|
|
18425
18354
|
});
|
|
18426
18355
|
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 +18362,7 @@ function registerEnvCommand(program2) {
|
|
|
18433
18362
|
const envs = await client.get(`/api/v1/projects/${projectId}/environments`);
|
|
18434
18363
|
output.success(envs);
|
|
18435
18364
|
} 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
|
-
}
|
|
18365
|
+
reportApiError(output, err, "ENV_LIST_FAILED");
|
|
18441
18366
|
}
|
|
18442
18367
|
});
|
|
18443
18368
|
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 +18389,7 @@ function registerEnvCommand(program2) {
|
|
|
18464
18389
|
await client.delete(`/api/v1/projects/${projectId}/environments/${envId}`);
|
|
18465
18390
|
output.success({ deleted: true, name });
|
|
18466
18391
|
} 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
|
-
}
|
|
18392
|
+
reportApiError(output, err, "ENV_DELETE_FAILED");
|
|
18472
18393
|
}
|
|
18473
18394
|
});
|
|
18474
18395
|
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 +18417,7 @@ function registerEnvCommand(program2) {
|
|
|
18496
18417
|
};
|
|
18497
18418
|
output.success(diff);
|
|
18498
18419
|
} 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
|
-
}
|
|
18420
|
+
reportApiError(output, err, "ENV_DIFF_FAILED");
|
|
18504
18421
|
}
|
|
18505
18422
|
});
|
|
18506
18423
|
}
|
|
@@ -18553,11 +18470,7 @@ function registerPromoteCommand(program2) {
|
|
|
18553
18470
|
});
|
|
18554
18471
|
output.success(promotion);
|
|
18555
18472
|
} 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
|
-
}
|
|
18473
|
+
reportApiError(output, err, "PROMOTE_FAILED");
|
|
18561
18474
|
}
|
|
18562
18475
|
});
|
|
18563
18476
|
}
|
|
@@ -18581,11 +18494,7 @@ function registerCanaryCommand(program2) {
|
|
|
18581
18494
|
const canary2 = await client.get(`/api/v1/projects/${projectId}/canary?envId=${opts.env}`);
|
|
18582
18495
|
output.success(canary2);
|
|
18583
18496
|
} 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
|
-
}
|
|
18497
|
+
reportApiError(output, err, "CANARY_STATUS_FAILED");
|
|
18589
18498
|
}
|
|
18590
18499
|
});
|
|
18591
18500
|
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 +18515,7 @@ function registerCanaryCommand(program2) {
|
|
|
18606
18515
|
const canary2 = await client.post(`/api/v1/projects/${projectId}/canary/complete`, { canaryId: opts.canaryId });
|
|
18607
18516
|
output.success(canary2);
|
|
18608
18517
|
} 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
|
-
}
|
|
18518
|
+
reportApiError(output, err, "CANARY_COMPLETE_FAILED");
|
|
18614
18519
|
}
|
|
18615
18520
|
});
|
|
18616
18521
|
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 +18540,7 @@ function registerCanaryCommand(program2) {
|
|
|
18635
18540
|
const canary2 = await client.post(`/api/v1/projects/${projectId}/canary/rollback`, { canaryId: opts.canaryId, reason: opts.reason });
|
|
18636
18541
|
output.success(canary2);
|
|
18637
18542
|
} 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
|
-
}
|
|
18543
|
+
reportApiError(output, err, "CANARY_ROLLBACK_FAILED");
|
|
18643
18544
|
}
|
|
18644
18545
|
});
|
|
18645
18546
|
}
|
|
@@ -18667,6 +18568,7 @@ var init_env = __esm(() => {
|
|
|
18667
18568
|
init_api_client();
|
|
18668
18569
|
init_config_store();
|
|
18669
18570
|
init_project_id();
|
|
18571
|
+
init_handle_api_error();
|
|
18670
18572
|
});
|
|
18671
18573
|
|
|
18672
18574
|
// src/commands/reports.ts
|
|
@@ -18983,16 +18885,13 @@ function parseChannelSpec(spec) {
|
|
|
18983
18885
|
return null;
|
|
18984
18886
|
}
|
|
18985
18887
|
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
|
-
}
|
|
18888
|
+
reportApiError(output, err, defaultCode);
|
|
18991
18889
|
}
|
|
18992
18890
|
var init_reports = __esm(() => {
|
|
18993
18891
|
init_src3();
|
|
18994
18892
|
init_api_client();
|
|
18995
18893
|
init_config_store();
|
|
18894
|
+
init_handle_api_error();
|
|
18996
18895
|
});
|
|
18997
18896
|
|
|
18998
18897
|
// src/commands/heal.ts
|
|
@@ -19110,11 +19009,7 @@ Healing configuration:
|
|
|
19110
19009
|
}
|
|
19111
19010
|
}
|
|
19112
19011
|
} 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
|
-
}
|
|
19012
|
+
reportApiError(output, err, "HEAL_CONFIG_FAILED");
|
|
19118
19013
|
}
|
|
19119
19014
|
});
|
|
19120
19015
|
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 +19041,7 @@ ${records.length} healing record(s):
|
|
|
19146
19041
|
}
|
|
19147
19042
|
}
|
|
19148
19043
|
} 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
|
-
}
|
|
19044
|
+
reportApiError(output, err, "HEAL_LIST_FAILED");
|
|
19154
19045
|
}
|
|
19155
19046
|
});
|
|
19156
19047
|
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 +19060,7 @@ ${records.length} healing record(s):
|
|
|
19169
19060
|
${formatRecord(record)}`);
|
|
19170
19061
|
}
|
|
19171
19062
|
} 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
|
-
}
|
|
19063
|
+
reportApiError(output, err, "HEAL_SHOW_FAILED");
|
|
19177
19064
|
}
|
|
19178
19065
|
});
|
|
19179
19066
|
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 +19080,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19193
19080
|
output.info(`Status: ${record.status}`);
|
|
19194
19081
|
}
|
|
19195
19082
|
} 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
|
-
}
|
|
19083
|
+
reportApiError(output, err, "HEAL_TRIGGER_FAILED");
|
|
19201
19084
|
}
|
|
19202
19085
|
});
|
|
19203
19086
|
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 +19098,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19215
19098
|
output.info(`Fix ${recordId} approved and queued for deployment.`);
|
|
19216
19099
|
}
|
|
19217
19100
|
} 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
|
-
}
|
|
19101
|
+
reportApiError(output, err, "HEAL_APPROVE_FAILED");
|
|
19223
19102
|
}
|
|
19224
19103
|
});
|
|
19225
19104
|
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 +19116,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19237
19116
|
output.info(`Fix ${recordId} rejected.`);
|
|
19238
19117
|
}
|
|
19239
19118
|
} 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
|
-
}
|
|
19119
|
+
reportApiError(output, err, "HEAL_REJECT_FAILED");
|
|
19245
19120
|
}
|
|
19246
19121
|
});
|
|
19247
19122
|
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 +19134,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19259
19134
|
output.info(`Fix ${recordId} rolled back.`);
|
|
19260
19135
|
}
|
|
19261
19136
|
} 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
|
-
}
|
|
19137
|
+
reportApiError(output, err, "HEAL_ROLLBACK_FAILED");
|
|
19267
19138
|
}
|
|
19268
19139
|
});
|
|
19269
19140
|
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 +19158,7 @@ Healing triggered. Record: ${record.id}`);
|
|
|
19287
19158
|
${formatDiff(record)}`);
|
|
19288
19159
|
}
|
|
19289
19160
|
} 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
|
-
}
|
|
19161
|
+
reportApiError(output, err, "HEAL_DIFF_FAILED");
|
|
19295
19162
|
}
|
|
19296
19163
|
});
|
|
19297
19164
|
}
|
|
@@ -19299,10 +19166,11 @@ var init_heal = __esm(() => {
|
|
|
19299
19166
|
init_src3();
|
|
19300
19167
|
init_api_client();
|
|
19301
19168
|
init_config_store();
|
|
19169
|
+
init_handle_api_error();
|
|
19302
19170
|
});
|
|
19303
19171
|
|
|
19304
19172
|
// src/lib/skill-installer.ts
|
|
19305
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as
|
|
19173
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
|
|
19306
19174
|
import { join as join13, dirname as dirname3 } from "node:path";
|
|
19307
19175
|
import { homedir as homedir2 } from "node:os";
|
|
19308
19176
|
import { fileURLToPath } from "node:url";
|
|
@@ -19325,7 +19193,7 @@ function installSkills(targetDir) {
|
|
|
19325
19193
|
for (const file of SKILL_FILES) {
|
|
19326
19194
|
const sourcePath = join13(sourceDir, file);
|
|
19327
19195
|
const targetPath = join13(targetDir, file);
|
|
19328
|
-
const content =
|
|
19196
|
+
const content = readFileSync11(sourcePath, "utf-8");
|
|
19329
19197
|
writeFileSync10(targetPath, content, "utf-8");
|
|
19330
19198
|
installedFiles.push(targetPath);
|
|
19331
19199
|
}
|
|
@@ -19380,6 +19248,10 @@ function registerInitCommand(program2) {
|
|
|
19380
19248
|
if (!existsSync13(gitignorePath)) {
|
|
19381
19249
|
writeFileSync11(gitignorePath, GITIGNORE_CONTENT2);
|
|
19382
19250
|
}
|
|
19251
|
+
const pkgPath = join14(projectDir, "package.json");
|
|
19252
|
+
if (!existsSync13(pkgPath)) {
|
|
19253
|
+
writeFileSync11(pkgPath, packageJsonTemplate(projectName));
|
|
19254
|
+
}
|
|
19383
19255
|
if (alreadyInitialized) {
|
|
19384
19256
|
output.info(`Re-checked dura project "${projectName}" in ${projectDir}`);
|
|
19385
19257
|
} else {
|
|
@@ -19412,7 +19284,13 @@ function registerInitCommand(program2) {
|
|
|
19412
19284
|
alreadyInitialized,
|
|
19413
19285
|
name: projectName,
|
|
19414
19286
|
path: projectDir,
|
|
19415
|
-
files: [
|
|
19287
|
+
files: [
|
|
19288
|
+
"dura.json",
|
|
19289
|
+
"package.json",
|
|
19290
|
+
"routes/hello.ts",
|
|
19291
|
+
"jobs/",
|
|
19292
|
+
".gitignore"
|
|
19293
|
+
]
|
|
19416
19294
|
});
|
|
19417
19295
|
if (!output.isJson()) {
|
|
19418
19296
|
output.info("");
|
|
@@ -19484,11 +19362,7 @@ function registerProjectsCommand(program2) {
|
|
|
19484
19362
|
const project = await client.get(`/api/v1/orgs/${orgId}/projects/${projectId}`);
|
|
19485
19363
|
output.success(project);
|
|
19486
19364
|
} 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
|
-
}
|
|
19365
|
+
reportApiError(output, err, "PROJECTS_GET_FAILED");
|
|
19492
19366
|
}
|
|
19493
19367
|
});
|
|
19494
19368
|
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 +19396,7 @@ function registerProjectsCommand(program2) {
|
|
|
19522
19396
|
]));
|
|
19523
19397
|
}
|
|
19524
19398
|
} 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
|
-
}
|
|
19399
|
+
reportApiError(output, err, "PROJECTS_LIST_FAILED");
|
|
19530
19400
|
}
|
|
19531
19401
|
});
|
|
19532
19402
|
}
|
|
@@ -19534,6 +19404,7 @@ var init_projects2 = __esm(() => {
|
|
|
19534
19404
|
init_src3();
|
|
19535
19405
|
init_api_client();
|
|
19536
19406
|
init_config_store();
|
|
19407
|
+
init_handle_api_error();
|
|
19537
19408
|
});
|
|
19538
19409
|
|
|
19539
19410
|
// src/index.ts
|
|
@@ -19575,6 +19446,7 @@ async function registerAllCommands(program2) {
|
|
|
19575
19446
|
const { registerTestCommand: registerTestCommand2 } = await Promise.resolve().then(() => (init_test(), exports_test));
|
|
19576
19447
|
const { registerDomainsCommand: registerDomainsCommand2 } = await Promise.resolve().then(() => (init_domains(), exports_domains));
|
|
19577
19448
|
const { registerEndpointKeysCommand: registerEndpointKeysCommand2 } = await Promise.resolve().then(() => (init_endpoint_keys2(), exports_endpoint_keys));
|
|
19449
|
+
const { registerEventsCommand: registerEventsCommand2 } = await Promise.resolve().then(() => (init_events(), exports_events));
|
|
19578
19450
|
const { registerUsageCommand: registerUsageCommand2 } = await Promise.resolve().then(() => (init_usage(), exports_usage));
|
|
19579
19451
|
const { registerMarketplaceCommand: registerMarketplaceCommand2 } = await Promise.resolve().then(() => (init_marketplace2(), exports_marketplace));
|
|
19580
19452
|
const { registerExportCommand: registerExportCommand2 } = await Promise.resolve().then(() => (init_export(), exports_export));
|
|
@@ -19619,6 +19491,7 @@ async function registerAllCommands(program2) {
|
|
|
19619
19491
|
registerTestCommand2(program2);
|
|
19620
19492
|
registerRunCommand2(program2);
|
|
19621
19493
|
registerScheduleCommand2(program2);
|
|
19494
|
+
registerEventsCommand2(program2);
|
|
19622
19495
|
registerStatusCommand2(program2);
|
|
19623
19496
|
registerLogsCommand2(program2);
|
|
19624
19497
|
registerUsageCommand2(program2);
|
|
@@ -19640,7 +19513,7 @@ async function registerAllCommands(program2) {
|
|
|
19640
19513
|
registerOpenApiCommand2(program2);
|
|
19641
19514
|
return program2;
|
|
19642
19515
|
}
|
|
19643
|
-
var CLI_VERSION = "0.3.
|
|
19516
|
+
var CLI_VERSION = "0.3.2";
|
|
19644
19517
|
var init_src3 = __esm(() => {
|
|
19645
19518
|
init_esm();
|
|
19646
19519
|
if (import.meta.url === `file://${realpathSync(process.argv[1] ?? "").replace(/\\/g, "/")}`) {
|
|
@@ -19657,4 +19530,4 @@ export {
|
|
|
19657
19530
|
CLI_VERSION
|
|
19658
19531
|
};
|
|
19659
19532
|
|
|
19660
|
-
//# debugId=
|
|
19533
|
+
//# debugId=BE2D824A7368E16F64756E2164756E21
|