Skip to content

Commit

Permalink
fix: some install command work
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Jul 29, 2022
1 parent 1adfd60 commit 1adbf01
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/commands/force/package/beta/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { Messages, SfProject } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { Package, PackagingSObjects, PackageInstallOptions } from '@salesforce/packaging';
import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
import { ensure } from '@salesforce/ts-types';
import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
import PackageInstallCreateRequest = PackagingSObjects.PackageInstallCreateRequest;

Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -75,23 +77,23 @@ export class PackageInstallCommand extends SfdxCommand {
const pkg = new Package({ connection });

const request: PackageInstallCreateRequest = {
SubscriberPackageVersionKey: await this.resolveSubscriberPackageVersionKey(this.flags.package)
SubscriberPackageVersionKey: this.resolveSubscriberPackageVersionKey(this.flags.package),
};

const installOptions: PackageInstallOptions = {
pollingTimeout: this.flags.wait,
pollingTimeout: ensure<Duration>(this.flags.wait),
};

return pkg.install(request, installOptions);
}

// Given a package version ID (04t) or an alias for the package,
// return the package version ID (aka SubscriberPackageVersionKey).
private async resolveSubscriberPackageVersionKey(idOrAlias: string): Promise<string> {
private resolveSubscriberPackageVersionKey(idOrAlias: string): string {
if (idOrAlias.startsWith('04t')) {
return idOrAlias;
} else {
let packageAliases: { [k: string ]: string };
let packageAliases: { [k: string]: string };
try {
const projectJson = SfProject.getInstance().getSfProjectJson();
packageAliases = projectJson.getContents().packageAliases ?? {};
Expand All @@ -105,7 +107,7 @@ export class PackageInstallCommand extends SfdxCommand {
if (!id.startsWith('04t')) {
// throw InvalidSubscriberPackageVersion - doesn't start with 04t
}
if ([15,18].includes(id.length)) {
if ([15, 18].includes(id.length)) {
// throw InvalidSubscriberPackageVersion - incorrect length
}
return id;
Expand Down

0 comments on commit 1adbf01

Please sign in to comment.