@quantum-hub/qhubctl 1.4.1 → 1.5.0
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.
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { input } from '@inquirer/prompts';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { error, spinner, stdout } from '../lib/output.js';
|
|
4
|
+
import { requireAuth } from '../model/command.js';
|
|
5
|
+
import QuantumHubService from '../service/quantum-hub-service.js';
|
|
6
|
+
import { readServiceConfig } from '../service/service-config-service.js';
|
|
7
|
+
const EXAMPLES = `
|
|
8
|
+
Examples:
|
|
9
|
+
$ qhubctl services build-status
|
|
10
|
+
$ qhubctl services build-status --id <serviceId>
|
|
11
|
+
$ qhubctl services build-status --id <serviceId> --json`;
|
|
12
|
+
export const servicesBuildStatusCommand = new Command('build-status')
|
|
13
|
+
.description('Show the build status of a service.')
|
|
14
|
+
.option('--id <value>', 'The ID of the service (reads from qhub.json if omitted)')
|
|
15
|
+
.option('--json', 'Output in JSON format', false)
|
|
16
|
+
.addHelpText('after', EXAMPLES)
|
|
17
|
+
.action(async (opts) => {
|
|
18
|
+
const userConfig = await requireAuth({ printContext: !opts.json });
|
|
19
|
+
const quantumHubService = new QuantumHubService(userConfig);
|
|
20
|
+
let serviceId = opts.id;
|
|
21
|
+
if (!serviceId) {
|
|
22
|
+
try {
|
|
23
|
+
const serviceConfig = readServiceConfig(process.cwd());
|
|
24
|
+
serviceId = serviceConfig.serviceId;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
serviceId = undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!serviceId) {
|
|
31
|
+
try {
|
|
32
|
+
serviceId = await input({ message: 'Enter the service ID:' });
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// user cancelled (Ctrl+C)
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!serviceId?.trim()) {
|
|
40
|
+
error('No service ID provided.');
|
|
41
|
+
}
|
|
42
|
+
const spin = spinner('Loading build status');
|
|
43
|
+
let buildJob;
|
|
44
|
+
try {
|
|
45
|
+
buildJob = await quantumHubService.getBuildJobByServiceId(serviceId);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
spin.fail('Failed to load build status');
|
|
49
|
+
error(err instanceof Error ? err.message : String(err));
|
|
50
|
+
}
|
|
51
|
+
spin.succeed('Build status loaded');
|
|
52
|
+
if (opts.json) {
|
|
53
|
+
stdout(JSON.stringify(buildJob, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
stdout();
|
|
57
|
+
stdout(`Service ID: ${serviceId}`);
|
|
58
|
+
stdout(`Status: ${buildJob.status ?? 'N/A'}`);
|
|
59
|
+
stdout(`Step: ${buildJob.step ?? 'N/A'}`);
|
|
60
|
+
stdout(`Started: ${buildJob.createdAt ?? 'N/A'}`);
|
|
61
|
+
stdout(`Finished: ${buildJob.finishedAt ?? 'N/A'}`);
|
|
62
|
+
if (buildJob.validationResult) {
|
|
63
|
+
const v = buildJob.validationResult;
|
|
64
|
+
stdout(`Validation: ${v.state ?? 'N/A'}`);
|
|
65
|
+
if (v.summary) {
|
|
66
|
+
stdout(` Summary: ${v.summary}`);
|
|
67
|
+
}
|
|
68
|
+
if (v.messages?.length) {
|
|
69
|
+
stdout(` Messages:`);
|
|
70
|
+
for (const msg of v.messages) {
|
|
71
|
+
stdout(` - ${msg}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
stdout();
|
|
76
|
+
});
|
package/dist/program.js
CHANGED
|
@@ -11,6 +11,7 @@ import { logoutCommand } from './commands/logout.js';
|
|
|
11
11
|
import { openapiCommand } from './commands/openapi.js';
|
|
12
12
|
import { runCommand } from './commands/run.js';
|
|
13
13
|
import { serveCommand } from './commands/serve.js';
|
|
14
|
+
import { servicesBuildStatusCommand } from './commands/services-build-status.js';
|
|
14
15
|
import { servicesListCommand } from './commands/services-list.js';
|
|
15
16
|
import { setContextCommand } from './commands/set-context.js';
|
|
16
17
|
import { upCommand } from './commands/up.js';
|
|
@@ -35,6 +36,7 @@ program.addCommand(serveCommand);
|
|
|
35
36
|
// Nested: services <subcommand>
|
|
36
37
|
const servicesCommand = new Command('services').description('Manage services');
|
|
37
38
|
servicesCommand.addCommand(servicesListCommand);
|
|
39
|
+
servicesCommand.addCommand(servicesBuildStatusCommand);
|
|
38
40
|
program.addCommand(servicesCommand);
|
|
39
41
|
program.addCommand(setContextCommand);
|
|
40
42
|
program.addCommand(upCommand);
|
|
@@ -12,6 +12,7 @@ export default class QuantumHubService extends CommandService {
|
|
|
12
12
|
createService(serviceConfig: ManagedServiceConfig, sourceCode: Blob, apiDefinition?: Blob): Promise<ServiceDto>;
|
|
13
13
|
getAccounts(): Promise<Account[]>;
|
|
14
14
|
getBuildJob(service: ServiceDto, serviceDefinition: ServiceDefinitionDto): Promise<BuildJobDto>;
|
|
15
|
+
getBuildJobByServiceId(serviceId: string): Promise<BuildJobDto>;
|
|
15
16
|
getJobById(id: string): Promise<HubPlatform.ServiceJobDto>;
|
|
16
17
|
getService(id: string): Promise<ServiceDto>;
|
|
17
18
|
getServices(): Promise<ServiceOverviewDto[]>;
|
|
@@ -75,6 +75,25 @@ export default class QuantumHubService extends CommandService {
|
|
|
75
75
|
throw new Error(errorMessage);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
async getBuildJobByServiceId(serviceId) {
|
|
79
|
+
const organizationId = this.userConfig.context?.isOrganization ? this.userConfig.context.id : undefined;
|
|
80
|
+
const service = await this.getService(serviceId);
|
|
81
|
+
const serviceDefinition = service?.serviceDefinitions?.[0];
|
|
82
|
+
if (!serviceDefinition?.id) {
|
|
83
|
+
throw new Error(`No service version found for service '${serviceId}'`);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return await this.serviceApi.getBuildStatus({
|
|
87
|
+
serviceId: service.id,
|
|
88
|
+
versionId: serviceDefinition.id,
|
|
89
|
+
xOrganizationId: organizationId,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const errorMessage = await handleError(error);
|
|
94
|
+
throw new Error(errorMessage);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
78
97
|
async getJobById(id) {
|
|
79
98
|
try {
|
|
80
99
|
return await this.apiClient.serviceJobs.getServiceJob({ "id": id });
|