@pmate/cli 0.24.29 → 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.js +124 -2
- package/package.json +1 -1
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",
|
|
@@ -19718,12 +19725,36 @@ var ServiceCommandHandler = class {
|
|
|
19718
19725
|
this.renderList(items, args.json);
|
|
19719
19726
|
return;
|
|
19720
19727
|
}
|
|
19721
|
-
case "get":
|
|
19722
|
-
case "view": {
|
|
19728
|
+
case "get": {
|
|
19723
19729
|
const record = await registry.getService(args.namespace, args.name);
|
|
19724
19730
|
this.renderJson(record, true);
|
|
19725
19731
|
return;
|
|
19726
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
|
+
}
|
|
19727
19758
|
case "create": {
|
|
19728
19759
|
const payload = this.readJsonFile(args.filePath);
|
|
19729
19760
|
await this.requireNamespace(payload, baseUrl);
|
|
@@ -20370,6 +20401,85 @@ var ServiceCommandHandler = class {
|
|
|
20370
20401
|
ui.info(`${time} ${item.environment} ${status}${message}`, item);
|
|
20371
20402
|
}
|
|
20372
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
|
+
}
|
|
20373
20483
|
async deleteServiceResources(service) {
|
|
20374
20484
|
switch (this.getServiceType(service)) {
|
|
20375
20485
|
case "vite":
|
|
@@ -20583,6 +20693,15 @@ function requireString(value, field) {
|
|
|
20583
20693
|
}
|
|
20584
20694
|
return value.trim();
|
|
20585
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
|
+
}
|
|
20586
20705
|
function splitPrimaryDomain(host) {
|
|
20587
20706
|
const normalized = host?.trim();
|
|
20588
20707
|
if (!normalized) {
|
|
@@ -22905,6 +23024,9 @@ function parseServiceArgs(tokens) {
|
|
|
22905
23024
|
case "--base-url":
|
|
22906
23025
|
baseUrl = requireValue6(rest, token);
|
|
22907
23026
|
break;
|
|
23027
|
+
case "--json":
|
|
23028
|
+
json = true;
|
|
23029
|
+
break;
|
|
22908
23030
|
default:
|
|
22909
23031
|
throw new Error(`Unknown service view option: ${token}`);
|
|
22910
23032
|
}
|