Skip to content

Commit

Permalink
fix: change name
Browse files Browse the repository at this point in the history
  • Loading branch information
btrn11 committed Dec 12, 2024
1 parent 3947f9a commit 2d89ac4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions schemas/package-pushupgrade-list.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/PackagePushUpgradeListResultArr",
"$ref": "#/definitions/PackagePushRequestListResultArr",
"definitions": {
"PackagePushUpgradeListResultArr": {
"PackagePushRequestListResultArr": {
"type": "array",
"items": {
"$ref": "#/definitions/PackagePushUpgradeListResult"
"$ref": "#/definitions/PackagePushRequestListResult"
}
},
"PackagePushUpgradeListResult": {
"PackagePushRequestListResult": {
"type": "object",
"properties": {
"PushRequestId": {
Expand Down
53 changes: 27 additions & 26 deletions src/commands/package/pushupgrade/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { Connection, Messages } from '@salesforce/core';
import { PackagePushUpgradeListResult, PackagePushUpgrade } from '@salesforce/packaging';
import { PackagePushRequestListResult, PackagePushUpgrade } from '@salesforce/packaging';
import chalk from 'chalk';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

Expand All @@ -16,9 +16,9 @@ const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_

type Status = 'Created' | 'Cancelled' | 'Pending' | 'In Progress' | 'Failed' | 'Succeeded';

export type PackagePushUpgradeListResultArr = PackagePushUpgradeListResult[];
export type PackagePushRequestListResultArr = PackagePushRequestListResult[];

export class PackagePushUpgradeListCommand extends SfCommand<PackagePushUpgradeListResultArr> {
export class PackagePushRequestListCommand extends SfCommand<PackagePushRequestListResultArr> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
Expand Down Expand Up @@ -48,29 +48,30 @@ export class PackagePushUpgradeListCommand extends SfCommand<PackagePushUpgradeL

private connection!: Connection;

public async run(): Promise<PackagePushUpgradeListResultArr> {
const { flags } = await this.parse(PackagePushUpgradeListCommand);
public async run(): Promise<PackagePushRequestListResultArr> {
const { flags } = await this.parse(PackagePushRequestListCommand);
this.connection = flags['target-dev-hub'].getConnection('61.0');

// Get results of query here
let results = await PackagePushUpgrade.list(this.connection, {
// Use const since we will add verbose later
const results = await PackagePushUpgrade.list(this.connection, {
packageId: flags.packageid!,
status: flags.status,
});

if (results.length === 0) {
this.warn('No results found');
} else {
if (flags.verbose) {
try {
results = fetchVerboseData(results);
} catch (err) {
const errMsg = typeof err === 'string' ? err : err instanceof Error ? err.message : 'unknown error';
this.warn(`error when retrieving verbose data due to: ${errMsg}`);
}
}
// if (flags.verbose) {
// try {
// results = fetchVerboseData(results);
// } catch (err) {
// const errMsg = typeof err === 'string' ? err : err instanceof Error ? err.message : 'unknown error';
// this.warn(`error when retrieving verbose data due to: ${errMsg}`);
// }
// }

const data = results.map((record: PackagePushUpgradeListResult) => ({
const data = results.map((record) => ({
PushRequestId: record?.PushRequestId,
PackageVersionId: record?.PackageVersionId,
PushRequestStatus: record?.PushRequestStatus,
Expand All @@ -86,14 +87,14 @@ export class PackagePushUpgradeListCommand extends SfCommand<PackagePushUpgradeL
}
}

function fetchVerboseData(results: PackagePushUpgradeListResultArr): PackagePushUpgradeListResultArr {
return results.map((result) => ({
...result,
...{
PushUpgradeRequestCreatedDateTime: '',
ActualUpgradeStartTime: '',
ActualUpgradeEndTime: '',
ActualDurationsOfPushUpgrades: 0,
},
}));
}
// function fetchVerboseData(results: PackagePushRequestListResultArr): PackagePushRequestListResultArr {
// return results.map((result) => ({
// ...result,
// ...{
// PushUpgradeRequestCreatedDateTime: '',
// ActualUpgradeStartTime: '',
// ActualUpgradeEndTime: '',
// ActualDurationsOfPushUpgrades: 0,
// },
// }));
// }

0 comments on commit 2d89ac4

Please sign in to comment.