From c76591565b90b048261fd0e922c537304018af12 Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 13:20:59 -0500 Subject: [PATCH 001/113] feat: add package push list feature --- messages/package_pushupgrade_list.md | 93 +++++++++++++++++++++++ src/commands/package/pushupgrade/list.ts | 97 ++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 messages/package_pushupgrade_list.md create mode 100644 src/commands/package/pushupgrade/list.ts diff --git a/messages/package_pushupgrade_list.md b/messages/package_pushupgrade_list.md new file mode 100644 index 00000000..c4b38a57 --- /dev/null +++ b/messages/package_pushupgrade_list.md @@ -0,0 +1,93 @@ +# summary + +List package version upgrades. + +# description + +Shows the details of each request to create a package version in the Dev Hub org. + +All filter parameters are applied using the AND logical operator (not OR). + +To get information about a specific request, run "<%= config.bin %> package version create report" and supply the request ID. + +# flags.package-id.summary + +Status of the version creation request, used to filter the list. + +# flags.scheduled-last-days.summary + +Filter the list output to display only converted package version. + +# flags.status.summary + +Status of the version creation request, used to filter the list. + +# flags.show-conversions-only.summary + +Filter the list output to display only converted package version. + +# flags.verbose.summary + +Displays additional information at a slight performance cost, such as the version name and number for each package version create request. + +# examples + +- List all package version creation requests in your default Dev Hub org: + + <%= config.bin %> <%= command.id %> + +- List package version creation requests from the last 3 days in the Dev Hub org with username devhub@example.com: + + <%= config.bin %> <%= command.id %> --created-last-days 3 --target-dev-hub + +- List package version creation requests with status Error: + + <%= config.bin %> <%= command.id %> --status Error + +- List package version creation requests with status InProgress: + + <%= config.bin %> <%= command.id %> --status InProgress + +- List package version creation requests with status Success that were created today: + + <%= config.bin %> <%= command.id %> --created-last-days 0 --status Success + +# id + +ID + +# status + +Status + +# package-id + +Package Id + +# packageVersionId + +Package Version Id + +# subscriberPackageVersionId + +Subscriber Package Version Id + +# branch + +Branch + +# tag + +Tag + +# installUrl + +Installation URL + +# createdBy + +Created By + +# convertedFromVersionId + +Converted From Version Id diff --git a/src/commands/package/pushupgrade/list.ts b/src/commands/package/pushupgrade/list.ts new file mode 100644 index 00000000..9150596b --- /dev/null +++ b/src/commands/package/pushupgrade/list.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { Flags, SfCommand } from '@salesforce/sf-plugins-core'; +import { Connection, Messages } from '@salesforce/core'; +import { PackagePushUpgradeListResult, PackagePushUpgrade } from '@salesforce/packaging'; +import chalk from 'chalk'; +import { requiredHubFlag } from '../../../utils/hubFlag.js'; + +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); +const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_pushupgrade_list'); + +type Status = 'Created' | 'Cancelled' | 'Pending' | 'In Progress' | 'Failed' | 'Succeeded'; + +export class PackagePushUpgradeListCommand extends SfCommand { + public static readonly summary = messages.getMessage('summary'); + public static readonly description = messages.getMessage('description'); + public static readonly examples = messages.getMessages('examples'); + public static readonly aliases = ['force:package:pushupgrade:list']; + public static readonly flags = { + 'target-dev-hub': requiredHubFlag, + packageid: Flags.string({ + char: 'p', + summary: messages.getMessage('flags.package-id.summary'), + }), + 'scheduled-last-days': Flags.integer({ + char: 'l', + deprecateAliases: true, + aliases: ['scheduledlastdays'], + summary: messages.getMessage('flags.scheduled-last-days.summary'), + }), + status: Flags.custom({ + options: ['Created', 'Cancelled', 'Pending', 'In Progress', 'Failed', 'Succeeded'], + })({ + char: 's', + summary: messages.getMessage('flags.status.summary'), + }), + verbose: Flags.boolean({ + summary: messages.getMessage('flags.verbose.summary'), + }), + }; + + private connection!: Connection; + + public async run(): Promise { + const { flags } = await this.parse(PackagePushUpgradeListCommand); + this.connection = flags['target-dev-hub'].getConnection('61.0'); + + // Get results of query here + let 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}`); + } + } + + const data = results.map((record: PackagePushUpgradeListResult) => ({ + PushRequestId: record?.PushRequestId, + PackageVersionId: record?.PackageVersionId, + PushRequestStatus: record?.PushRequestStatus, + PushRequestScheduledDateTime: 'test', + NumOrgsScheduled: 0, + NumOrgsUpgradedFail: 0, + NumOrgsUpgradedSuccess: 0, + })); + + this.table({ data, overflow: 'wrap', title: chalk.blue(`Push Upgrade List: [${results.length}]`) }); + } + return results; + } +} + +function fetchVerboseData(results: PackagePushUpgradeListResult[]): PackagePushUpgradeListResult[] { + return results.map((result) => ({ + ...result, + ...{ + PushUpgradeRequestCreatedDateTime: '', + ActualUpgradeStartTime: '', + ActualUpgradeEndTime: '', + ActualDurationsOfPushUpgrades: 0, + }, + })); +} From 1175b464f08b0ed7f8ddcf6d19f2c9f07e3ce88e Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 13:34:28 -0500 Subject: [PATCH 002/113] fix: export required type --- src/commands/package/pushupgrade/list.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commands/package/pushupgrade/list.ts b/src/commands/package/pushupgrade/list.ts index 9150596b..01c06932 100644 --- a/src/commands/package/pushupgrade/list.ts +++ b/src/commands/package/pushupgrade/list.ts @@ -16,7 +16,9 @@ const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_ type Status = 'Created' | 'Cancelled' | 'Pending' | 'In Progress' | 'Failed' | 'Succeeded'; -export class PackagePushUpgradeListCommand extends SfCommand { +export type PackagePushUpgradeListResultArr = PackagePushUpgradeListResult[]; + +export class PackagePushUpgradeListCommand extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -46,7 +48,7 @@ export class PackagePushUpgradeListCommand extends SfCommand { + public async run(): Promise { const { flags } = await this.parse(PackagePushUpgradeListCommand); this.connection = flags['target-dev-hub'].getConnection('61.0'); @@ -84,7 +86,7 @@ export class PackagePushUpgradeListCommand extends SfCommand ({ ...result, ...{ From 137bfdd7f70e82e6f3d47a6f01aaa4e9df7a909e Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 13:39:48 -0500 Subject: [PATCH 003/113] feat: add pushupgrade list schema file --- schemas/package-pushupgrade-list.json | 100 ++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 schemas/package-pushupgrade-list.json diff --git a/schemas/package-pushupgrade-list.json b/schemas/package-pushupgrade-list.json new file mode 100644 index 00000000..5c9f6452 --- /dev/null +++ b/schemas/package-pushupgrade-list.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/CreateListCommandResult", + "definitions": { + "CreateListCommandResult": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "VersionName": { + "type": "string" + }, + "VersionNumber": { + "type": ["string", "null"] + }, + "Id": { + "type": "string" + }, + "Status": { + "$ref": "#/definitions/PackagingSObjects.Package2VersionStatus" + }, + "Package2Id": { + "type": "string" + }, + "Package2Name": { + "type": ["string", "null"] + }, + "Package2VersionId": { + "type": "string" + }, + "SubscriberPackageVersionId": { + "type": ["string", "null"] + }, + "Tag": { + "type": "string" + }, + "Branch": { + "type": "string" + }, + "Error": { + "type": "array", + "items": {} + }, + "CreatedDate": { + "type": "string" + }, + "HasMetadataRemoved": { + "type": ["boolean", "null"] + }, + "HasPassedCodeCoverageCheck": { + "type": ["boolean", "null"] + }, + "CodeCoverage": { + "type": ["number", "null"] + }, + "CreatedBy": { + "type": "string" + }, + "ConvertedFromVersionId": { + "type": ["string", "null"] + } + }, + "required": [ + "Branch", + "CodeCoverage", + "ConvertedFromVersionId", + "CreatedBy", + "CreatedDate", + "Error", + "HasMetadataRemoved", + "HasPassedCodeCoverageCheck", + "Id", + "Package2Id", + "Package2Name", + "Package2VersionId", + "Status", + "SubscriberPackageVersionId", + "Tag", + "VersionNumber" + ] + } + }, + "PackagingSObjects.Package2VersionStatus": { + "type": "string", + "enum": [ + "Queued", + "InProgress", + "Success", + "Error", + "Initializing", + "VerifyingFeaturesAndSettings", + "VerifyingDependencies", + "VerifyingMetadata", + "FinalizingPackageVersion", + "PerformingValidations" + ] + } + } +} From 38dcf0c15e07e08e1ebb19ae89d4a20ac198370d Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 14:47:32 -0500 Subject: [PATCH 004/113] fix: edit pushupgrade list schema file --- schemas/package-pushupgrade-list.json | 128 ++++++++------------------ 1 file changed, 38 insertions(+), 90 deletions(-) diff --git a/schemas/package-pushupgrade-list.json b/schemas/package-pushupgrade-list.json index 5c9f6452..3fedeeeb 100644 --- a/schemas/package-pushupgrade-list.json +++ b/schemas/package-pushupgrade-list.json @@ -1,100 +1,48 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "#/definitions/CreateListCommandResult", + "$ref": "#/definitions/PackagePushUpgradeListResultArr", "definitions": { - "CreateListCommandResult": { + "PackagePushUpgradeListResultArr": { "type": "array", "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "VersionName": { - "type": "string" - }, - "VersionNumber": { - "type": ["string", "null"] - }, - "Id": { - "type": "string" - }, - "Status": { - "$ref": "#/definitions/PackagingSObjects.Package2VersionStatus" - }, - "Package2Id": { - "type": "string" - }, - "Package2Name": { - "type": ["string", "null"] - }, - "Package2VersionId": { - "type": "string" - }, - "SubscriberPackageVersionId": { - "type": ["string", "null"] - }, - "Tag": { - "type": "string" - }, - "Branch": { - "type": "string" - }, - "Error": { - "type": "array", - "items": {} - }, - "CreatedDate": { - "type": "string" - }, - "HasMetadataRemoved": { - "type": ["boolean", "null"] - }, - "HasPassedCodeCoverageCheck": { - "type": ["boolean", "null"] - }, - "CodeCoverage": { - "type": ["number", "null"] - }, - "CreatedBy": { - "type": "string" - }, - "ConvertedFromVersionId": { - "type": ["string", "null"] - } - }, - "required": [ - "Branch", - "CodeCoverage", - "ConvertedFromVersionId", - "CreatedBy", - "CreatedDate", - "Error", - "HasMetadataRemoved", - "HasPassedCodeCoverageCheck", - "Id", - "Package2Id", - "Package2Name", - "Package2VersionId", - "Status", - "SubscriberPackageVersionId", - "Tag", - "VersionNumber" - ] + "$ref": "#/definitions/PackagePushUpgradeListResult" } }, - "PackagingSObjects.Package2VersionStatus": { - "type": "string", - "enum": [ - "Queued", - "InProgress", - "Success", - "Error", - "Initializing", - "VerifyingFeaturesAndSettings", - "VerifyingDependencies", - "VerifyingMetadata", - "FinalizingPackageVersion", - "PerformingValidations" - ] + "PackagePushUpgradeListResult": { + "type": "object", + "properties": { + "PushRequestId": { + "type": "string" + }, + "PackageVersionId": { + "type": "string" + }, + "PushRequestStatus": { + "type": "string" + }, + "PushRequestScheduledDateTime": { + "type": "string" + }, + "NumOrgsScheduled": { + "type": "number" + }, + "NumOrgsUpgradedFail": { + "type": "number" + }, + "NumOrgsUpgradedSuccess": { + "type": "number" + } + }, + "required": [ + "PushRequestId", + "PackageVersionId", + "PushRequestStatus", + "PushRequestScheduledDateTime", + "NumOrgsScheduled", + "NumOrgsUpgradedSuccess", + "NumOrgsUpgradedFail" + ], + "additionalProperties": false } } } From 3947f9afae2c0d239c1bad29222b95860afe7e5c Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 14:50:50 -0500 Subject: [PATCH 005/113] fix: edit pushupgrade list md file --- messages/package_pushupgrade_list.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/package_pushupgrade_list.md b/messages/package_pushupgrade_list.md index c4b38a57..27060a7a 100644 --- a/messages/package_pushupgrade_list.md +++ b/messages/package_pushupgrade_list.md @@ -1,6 +1,6 @@ # summary -List package version upgrades. +List package push upgrades. # description From 2d89ac4bf4222df2989058f5c0a0f249cf525ea8 Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Thu, 12 Dec 2024 15:25:34 -0500 Subject: [PATCH 006/113] fix: change name --- schemas/package-pushupgrade-list.json | 8 ++-- src/commands/package/pushupgrade/list.ts | 53 ++++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/schemas/package-pushupgrade-list.json b/schemas/package-pushupgrade-list.json index 3fedeeeb..1adc60d8 100644 --- a/schemas/package-pushupgrade-list.json +++ b/schemas/package-pushupgrade-list.json @@ -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": { diff --git a/src/commands/package/pushupgrade/list.ts b/src/commands/package/pushupgrade/list.ts index 01c06932..721f6f2a 100644 --- a/src/commands/package/pushupgrade/list.ts +++ b/src/commands/package/pushupgrade/list.ts @@ -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'; @@ -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 { +export class PackagePushRequestListCommand extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -48,12 +48,13 @@ export class PackagePushUpgradeListCommand extends SfCommand { - const { flags } = await this.parse(PackagePushUpgradeListCommand); + public async run(): Promise { + 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, }); @@ -61,16 +62,16 @@ export class PackagePushUpgradeListCommand extends SfCommand ({ + const data = results.map((record) => ({ PushRequestId: record?.PushRequestId, PackageVersionId: record?.PackageVersionId, PushRequestStatus: record?.PushRequestStatus, @@ -86,14 +87,14 @@ export class PackagePushUpgradeListCommand extends SfCommand ({ - ...result, - ...{ - PushUpgradeRequestCreatedDateTime: '', - ActualUpgradeStartTime: '', - ActualUpgradeEndTime: '', - ActualDurationsOfPushUpgrades: 0, - }, - })); -} +// function fetchVerboseData(results: PackagePushRequestListResultArr): PackagePushRequestListResultArr { +// return results.map((result) => ({ +// ...result, +// ...{ +// PushUpgradeRequestCreatedDateTime: '', +// ActualUpgradeStartTime: '', +// ActualUpgradeEndTime: '', +// ActualDurationsOfPushUpgrades: 0, +// }, +// })); +// } From 5ee2cc3f5baa5770195cde7de724b2b0cd3c709f Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Fri, 13 Dec 2024 11:48:15 -0500 Subject: [PATCH 007/113] fix: update push upgrade list md file --- messages/package_pushupgrade_list.md | 56 ++++++---------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/messages/package_pushupgrade_list.md b/messages/package_pushupgrade_list.md index 27060a7a..dfe08485 100644 --- a/messages/package_pushupgrade_list.md +++ b/messages/package_pushupgrade_list.md @@ -4,53 +4,45 @@ List package push upgrades. # description -Shows the details of each request to create a package version in the Dev Hub org. +Shows the details of each request to create a push upgrade in the Dev Hub org. All filter parameters are applied using the AND logical operator (not OR). -To get information about a specific request, run "<%= config.bin %> package version create report" and supply the request ID. +To get information about a specific request, run "<%= config.bin %> package pushupgrade report" and supply the request ID. # flags.package-id.summary -Status of the version creation request, used to filter the list. +Status of the push upgrade request, used to filter the list. # flags.scheduled-last-days.summary -Filter the list output to display only converted package version. +Filter the list output to display only push upgrade requests from a specific amount of days. # flags.status.summary -Status of the version creation request, used to filter the list. - -# flags.show-conversions-only.summary - -Filter the list output to display only converted package version. +Status of the push upgrade request, used to filter the list. # flags.verbose.summary -Displays additional information at a slight performance cost, such as the version name and number for each package version create request. +Displays additional information at a slight performance cost, such as number of orgs scheduled for push upgrade, orgs successfully upgraded, etc. # examples -- List all package version creation requests in your default Dev Hub org: +- List all package push upgrade requests in your default Dev Hub org: <%= config.bin %> <%= command.id %> -- List package version creation requests from the last 3 days in the Dev Hub org with username devhub@example.com: +- List package push upgrade requests scheduled from the last 3 days in the Dev Hub org with username devhub@example.com: - <%= config.bin %> <%= command.id %> --created-last-days 3 --target-dev-hub + <%= config.bin %> <%= command.id %> --scheduled-last-days 3 --target-dev-hub -- List package version creation requests with status Error: +- List package push upgrade requests with status Error: <%= config.bin %> <%= command.id %> --status Error -- List package version creation requests with status InProgress: - - <%= config.bin %> <%= command.id %> --status InProgress - -- List package version creation requests with status Success that were created today: +- List package push upgrade requests with status Success: - <%= config.bin %> <%= command.id %> --created-last-days 0 --status Success + <%= config.bin %> <%= command.id %> --status Success # id @@ -67,27 +59,3 @@ Package Id # packageVersionId Package Version Id - -# subscriberPackageVersionId - -Subscriber Package Version Id - -# branch - -Branch - -# tag - -Tag - -# installUrl - -Installation URL - -# createdBy - -Created By - -# convertedFromVersionId - -Converted From Version Id From 1616eaf7e38a796f8887a16391b9dd39ff0ea293 Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Fri, 13 Dec 2024 11:59:07 -0500 Subject: [PATCH 008/113] feat: add beta state to pu list command --- src/commands/package/pushupgrade/list.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/package/pushupgrade/list.ts b/src/commands/package/pushupgrade/list.ts index 721f6f2a..ba622154 100644 --- a/src/commands/package/pushupgrade/list.ts +++ b/src/commands/package/pushupgrade/list.ts @@ -22,6 +22,7 @@ export class PackagePushRequestListCommand extends SfCommand Date: Fri, 13 Dec 2024 13:17:01 -0500 Subject: [PATCH 009/113] feat: hide pu command --- src/commands/package/pushupgrade/list.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/package/pushupgrade/list.ts b/src/commands/package/pushupgrade/list.ts index ba622154..eb8922c2 100644 --- a/src/commands/package/pushupgrade/list.ts +++ b/src/commands/package/pushupgrade/list.ts @@ -22,6 +22,7 @@ export class PackagePushRequestListCommand extends SfCommand