@pmate/cli 0.24.28 → 0.24.30
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/index.d.ts +9 -0
- package/dist/index.js +171 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -936,6 +936,15 @@ type ServiceCommandArgs = {
|
|
|
936
936
|
history: boolean;
|
|
937
937
|
search?: string;
|
|
938
938
|
follow: boolean;
|
|
939
|
+
} | {
|
|
940
|
+
type: Command.Service;
|
|
941
|
+
action: "deploy-logs" | "deploy-history";
|
|
942
|
+
namespace: string;
|
|
943
|
+
name: string;
|
|
944
|
+
env?: string;
|
|
945
|
+
page: number;
|
|
946
|
+
baseUrl?: string;
|
|
947
|
+
json: boolean;
|
|
939
948
|
} | {
|
|
940
949
|
type: Command.Service;
|
|
941
950
|
action: "env-list";
|
package/dist/index.js
CHANGED
|
@@ -18201,6 +18201,13 @@ var ServiceRegistryClient = class {
|
|
|
18201
18201
|
);
|
|
18202
18202
|
return payload.items;
|
|
18203
18203
|
}
|
|
18204
|
+
async listServiceEnvs(serviceId) {
|
|
18205
|
+
const payload = await this.request(
|
|
18206
|
+
"GET",
|
|
18207
|
+
`/services/by-id/${encodeURIComponent(serviceId)}/envs`
|
|
18208
|
+
);
|
|
18209
|
+
return payload.items;
|
|
18210
|
+
}
|
|
18204
18211
|
async resolveEnv(serviceId, options) {
|
|
18205
18212
|
return this.requestWithBody(
|
|
18206
18213
|
"POST",
|
|
@@ -18226,6 +18233,16 @@ var ServiceRegistryClient = class {
|
|
|
18226
18233
|
input
|
|
18227
18234
|
);
|
|
18228
18235
|
}
|
|
18236
|
+
async listDeployHistory(serviceId, options = {}) {
|
|
18237
|
+
const params = new URLSearchParams();
|
|
18238
|
+
if (options.page !== void 0) {
|
|
18239
|
+
params.set("page", String(options.page));
|
|
18240
|
+
}
|
|
18241
|
+
return this.request(
|
|
18242
|
+
"GET",
|
|
18243
|
+
`/services/by-id/${encodeURIComponent(serviceId)}/deploy-history${params.size > 0 ? `?${params.toString()}` : ""}`
|
|
18244
|
+
);
|
|
18245
|
+
}
|
|
18229
18246
|
async pullEnv(serviceId, options) {
|
|
18230
18247
|
const pathname = `/services/by-id/${encodeURIComponent(serviceId)}/env/pull`;
|
|
18231
18248
|
const response = await fetch(`${this.resolveBaseUrl()}${pathname}`, {
|
|
@@ -19708,12 +19725,36 @@ var ServiceCommandHandler = class {
|
|
|
19708
19725
|
this.renderList(items, args.json);
|
|
19709
19726
|
return;
|
|
19710
19727
|
}
|
|
19711
|
-
case "get":
|
|
19712
|
-
case "view": {
|
|
19728
|
+
case "get": {
|
|
19713
19729
|
const record = await registry.getService(args.namespace, args.name);
|
|
19714
19730
|
this.renderJson(record, true);
|
|
19715
19731
|
return;
|
|
19716
19732
|
}
|
|
19733
|
+
case "view": {
|
|
19734
|
+
const record = await registry.getService(args.namespace, args.name);
|
|
19735
|
+
const [envsResult, envVarsResult] = await Promise.allSettled([
|
|
19736
|
+
registry.listServiceEnvs(record.id),
|
|
19737
|
+
registry.listEnvItems(record.id, { includeSecretMeta: true })
|
|
19738
|
+
]);
|
|
19739
|
+
const envs = envsResult.status === "fulfilled" ? envsResult.value : [];
|
|
19740
|
+
const envVars = envVarsResult.status === "fulfilled" ? envVarsResult.value : [];
|
|
19741
|
+
const errors = [
|
|
19742
|
+
envsResult.status === "rejected" ? { section: "envs", message: errorMessage(envsResult.reason) } : void 0,
|
|
19743
|
+
envVarsResult.status === "rejected" ? { section: "envVars", message: errorMessage(envVarsResult.reason) } : void 0
|
|
19744
|
+
].filter((item) => item !== void 0);
|
|
19745
|
+
const payload = {
|
|
19746
|
+
service: record,
|
|
19747
|
+
envs,
|
|
19748
|
+
envVars,
|
|
19749
|
+
...errors.length > 0 ? { errors } : {}
|
|
19750
|
+
};
|
|
19751
|
+
if (args.json) {
|
|
19752
|
+
this.renderJson(payload, true);
|
|
19753
|
+
} else {
|
|
19754
|
+
this.renderServiceView(payload);
|
|
19755
|
+
}
|
|
19756
|
+
return;
|
|
19757
|
+
}
|
|
19717
19758
|
case "create": {
|
|
19718
19759
|
const payload = this.readJsonFile(args.filePath);
|
|
19719
19760
|
await this.requireNamespace(payload, baseUrl);
|
|
@@ -19829,6 +19870,22 @@ var ServiceCommandHandler = class {
|
|
|
19829
19870
|
});
|
|
19830
19871
|
return;
|
|
19831
19872
|
}
|
|
19873
|
+
case "deploy-logs":
|
|
19874
|
+
case "deploy-history": {
|
|
19875
|
+
const serviceId = formatNamespacedDisplayId(args.namespace, args.name);
|
|
19876
|
+
const payload = await registry.listDeployHistory(serviceId, {
|
|
19877
|
+
page: args.page
|
|
19878
|
+
});
|
|
19879
|
+
const items = args.env ? payload.items.filter((item) => item.environment === args.env) : payload.items;
|
|
19880
|
+
this.renderDeployHistory(
|
|
19881
|
+
{
|
|
19882
|
+
...payload,
|
|
19883
|
+
items
|
|
19884
|
+
},
|
|
19885
|
+
args.json
|
|
19886
|
+
);
|
|
19887
|
+
return;
|
|
19888
|
+
}
|
|
19832
19889
|
case "env-list": {
|
|
19833
19890
|
const payload = await this.request(
|
|
19834
19891
|
baseUrl,
|
|
@@ -20328,6 +20385,101 @@ var ServiceCommandHandler = class {
|
|
|
20328
20385
|
ui.info(formatNamespacedDisplayId(item.namespace, item.name), item);
|
|
20329
20386
|
}
|
|
20330
20387
|
}
|
|
20388
|
+
renderDeployHistory(payload, asJson) {
|
|
20389
|
+
if (asJson) {
|
|
20390
|
+
ui.plain(JSON.stringify(payload, null, 2));
|
|
20391
|
+
return;
|
|
20392
|
+
}
|
|
20393
|
+
if (payload.items.length === 0) {
|
|
20394
|
+
ui.warn(`No deploy logs found for ${payload.serviceId}.`);
|
|
20395
|
+
return;
|
|
20396
|
+
}
|
|
20397
|
+
for (const item of payload.items) {
|
|
20398
|
+
const time = new Date(item.createdAt).toISOString();
|
|
20399
|
+
const status = item.status === "success" ? "success" : "failed";
|
|
20400
|
+
const message = item.message ? ` ${item.message}` : "";
|
|
20401
|
+
ui.info(`${time} ${item.environment} ${status}${message}`, item);
|
|
20402
|
+
}
|
|
20403
|
+
}
|
|
20404
|
+
renderServiceView(payload) {
|
|
20405
|
+
const service = payload.service;
|
|
20406
|
+
ui.title(`Service ${service.id}`);
|
|
20407
|
+
ui.plain("");
|
|
20408
|
+
this.renderField("Type", this.getServiceType(service));
|
|
20409
|
+
this.renderField("Repository", "repository" in service ? service.repository : void 0);
|
|
20410
|
+
this.renderField("Directory", "dir" in service ? service.dir : void 0);
|
|
20411
|
+
this.renderField("Status", "status" in service ? service.status : void 0);
|
|
20412
|
+
this.renderField("Updated", formatTimestamp("updatedAt" in service ? service.updatedAt : void 0));
|
|
20413
|
+
ui.plain("");
|
|
20414
|
+
ui.title("Environments");
|
|
20415
|
+
if (payload.envs.length === 0) {
|
|
20416
|
+
ui.plain(" none");
|
|
20417
|
+
} else {
|
|
20418
|
+
for (const env of payload.envs) {
|
|
20419
|
+
ui.plain(` ${env.name}`);
|
|
20420
|
+
const runtime = env.runtime;
|
|
20421
|
+
if (runtime) {
|
|
20422
|
+
this.renderField("Runtime", runtime.type, 4);
|
|
20423
|
+
this.renderRuntimeFields(runtime);
|
|
20424
|
+
} else {
|
|
20425
|
+
this.renderField("Runtime", "none", 4);
|
|
20426
|
+
}
|
|
20427
|
+
const network = env.network;
|
|
20428
|
+
if (network) {
|
|
20429
|
+
this.renderField("Network", network.type, 4);
|
|
20430
|
+
this.renderField("Domain", network.domain ? `https://${network.domain}` : void 0, 4);
|
|
20431
|
+
} else {
|
|
20432
|
+
this.renderField("Network", "none", 4);
|
|
20433
|
+
}
|
|
20434
|
+
}
|
|
20435
|
+
}
|
|
20436
|
+
ui.plain("");
|
|
20437
|
+
ui.title("Env Vars");
|
|
20438
|
+
if (payload.envVars.length === 0) {
|
|
20439
|
+
ui.plain(" none");
|
|
20440
|
+
} else {
|
|
20441
|
+
for (const item of payload.envVars) {
|
|
20442
|
+
const key = item.key ?? item.name ?? item.id ?? "unknown";
|
|
20443
|
+
const scope = item.scope ? ` [${item.scope}]` : "";
|
|
20444
|
+
const kind = item.kind ? ` ${item.kind}` : "";
|
|
20445
|
+
const value = item.value !== void 0 ? ` = ${item.value}` : "";
|
|
20446
|
+
ui.plain(` ${key}${scope}${kind}${value}`);
|
|
20447
|
+
}
|
|
20448
|
+
}
|
|
20449
|
+
for (const error of payload.errors ?? []) {
|
|
20450
|
+
ui.warn(`Could not load ${error.section}`, { message: error.message });
|
|
20451
|
+
}
|
|
20452
|
+
}
|
|
20453
|
+
renderRuntimeFields(runtime) {
|
|
20454
|
+
if ("bucket" in runtime) {
|
|
20455
|
+
this.renderField("Bucket", runtime.bucket, 4);
|
|
20456
|
+
}
|
|
20457
|
+
if ("server" in runtime) {
|
|
20458
|
+
this.renderField("Server", runtime.server, 4);
|
|
20459
|
+
}
|
|
20460
|
+
if ("port" in runtime) {
|
|
20461
|
+
this.renderField("Port", runtime.port, 4);
|
|
20462
|
+
}
|
|
20463
|
+
if ("region" in runtime) {
|
|
20464
|
+
this.renderField("Region", runtime.region, 4);
|
|
20465
|
+
}
|
|
20466
|
+
if ("functionName" in runtime) {
|
|
20467
|
+
this.renderField("Function", runtime.functionName, 4);
|
|
20468
|
+
}
|
|
20469
|
+
if ("command" in runtime) {
|
|
20470
|
+
this.renderField("Command", runtime.command, 4);
|
|
20471
|
+
}
|
|
20472
|
+
if ("cwd" in runtime) {
|
|
20473
|
+
this.renderField("Cwd", runtime.cwd, 4);
|
|
20474
|
+
}
|
|
20475
|
+
}
|
|
20476
|
+
renderField(label, value, indent = 0) {
|
|
20477
|
+
if (value === void 0 || value === null || value === "") {
|
|
20478
|
+
return;
|
|
20479
|
+
}
|
|
20480
|
+
const padding = " ".repeat(indent);
|
|
20481
|
+
ui.plain(`${padding}${label.padEnd(11)} ${String(value)}`);
|
|
20482
|
+
}
|
|
20331
20483
|
async deleteServiceResources(service) {
|
|
20332
20484
|
switch (this.getServiceType(service)) {
|
|
20333
20485
|
case "vite":
|
|
@@ -20541,6 +20693,15 @@ function requireString(value, field) {
|
|
|
20541
20693
|
}
|
|
20542
20694
|
return value.trim();
|
|
20543
20695
|
}
|
|
20696
|
+
function errorMessage(error) {
|
|
20697
|
+
return error instanceof Error ? error.message : String(error);
|
|
20698
|
+
}
|
|
20699
|
+
function formatTimestamp(value) {
|
|
20700
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
20701
|
+
return void 0;
|
|
20702
|
+
}
|
|
20703
|
+
return new Date(value).toISOString();
|
|
20704
|
+
}
|
|
20544
20705
|
function splitPrimaryDomain(host) {
|
|
20545
20706
|
const normalized = host?.trim();
|
|
20546
20707
|
if (!normalized) {
|
|
@@ -22863,6 +23024,9 @@ function parseServiceArgs(tokens) {
|
|
|
22863
23024
|
case "--base-url":
|
|
22864
23025
|
baseUrl = requireValue6(rest, token);
|
|
22865
23026
|
break;
|
|
23027
|
+
case "--json":
|
|
23028
|
+
json = true;
|
|
23029
|
+
break;
|
|
22866
23030
|
default:
|
|
22867
23031
|
throw new Error(`Unknown service view option: ${token}`);
|
|
22868
23032
|
}
|
|
@@ -22877,7 +23041,7 @@ function parseServiceArgs(tokens) {
|
|
|
22877
23041
|
json
|
|
22878
23042
|
};
|
|
22879
23043
|
}
|
|
22880
|
-
if (action === "get" || action === "delete" || action === "deploy" || action === "stop" || action === "init" || action === "log") {
|
|
23044
|
+
if (action === "get" || action === "delete" || action === "deploy" || action === "stop" || action === "init" || action === "log" || action === "deploy-logs" || action === "deploy-history") {
|
|
22881
23045
|
const ref = rest.shift();
|
|
22882
23046
|
if (!ref || ref.startsWith("-")) {
|
|
22883
23047
|
throw new Error(`Usage: service ${action} <ns:objectId> [--base-url <url>] [--json]`);
|
|
@@ -22901,7 +23065,7 @@ function parseServiceArgs(tokens) {
|
|
|
22901
23065
|
cwd = requireValue6(rest, token);
|
|
22902
23066
|
break;
|
|
22903
23067
|
case "--env":
|
|
22904
|
-
if (action !== "deploy" && action !== "init" && action !== "stop") {
|
|
23068
|
+
if (action !== "deploy" && action !== "init" && action !== "stop" && action !== "deploy-logs" && action !== "deploy-history") {
|
|
22905
23069
|
throw new Error(`Unknown service ${action} option: ${token}`);
|
|
22906
23070
|
}
|
|
22907
23071
|
env = requireValue6(rest, token);
|
|
@@ -22932,6 +23096,9 @@ function parseServiceArgs(tokens) {
|
|
|
22932
23096
|
if (action === "log") {
|
|
22933
23097
|
return { type: "service" /* Service */, action, namespace, name, baseUrl, json, page, history, search, follow };
|
|
22934
23098
|
}
|
|
23099
|
+
if (action === "deploy-logs" || action === "deploy-history") {
|
|
23100
|
+
return { type: "service" /* Service */, action, namespace, name, env, page, baseUrl, json };
|
|
23101
|
+
}
|
|
22935
23102
|
if (action === "deploy" || action === "stop") {
|
|
22936
23103
|
if (action === "deploy" && !env) {
|
|
22937
23104
|
throw new Error("Missing required option --env for service deploy");
|