Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update imports to use 4 main classes #152

Merged
merged 7 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@salesforce/command": "^5.2.17",
"@salesforce/core": "^3.31.15",
"@salesforce/kit": "^1.7.0",
"@salesforce/packaging": "^0.1.18",
"@salesforce/packaging": "^1.0.1",
"chalk": "^4.1.2",
"tslib": "^2"
},
Expand Down Expand Up @@ -181,4 +181,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 2 additions & 2 deletions src/commands/force/package/beta/installed/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import * as os from 'os';
import { Messages } from '@salesforce/core';
import { SfdxCommand } from '@salesforce/command';
import { packageInstalledList } from '@salesforce/packaging';
import { CliUx } from '@oclif/core';
import { SubscriberPackageVersion } from '@salesforce/packaging';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_installed_list');
Expand All @@ -31,7 +31,7 @@ export class PackageInstalledListCommand extends SfdxCommand {
public static readonly requiresProject = true;

public async run(): Promise<PackageInstalledListResult[]> {
const result = await packageInstalledList(this.org.getConnection());
const result = await SubscriberPackageVersion.installedList(this.org.getConnection());

const records = result.map((record) => ({
Id: record.Id,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/force/package/beta/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as os from 'os';
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { getPackageAliasesFromId, Package, PackagingSObjects } from '@salesforce/packaging';
import { Package, PackagingSObjects } from '@salesforce/packaging';
import * as chalk from 'chalk';

Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -77,7 +77,7 @@ export class PackageListCommand extends SfdxCommand {
NamespacePrefix,
ContainerOptions,
ConvertedFromPackageId,
Alias: getPackageAliasesFromId(Id, this.project).join(),
Alias: this.project.getAliasesFromPackageId(Id).join(),
IsOrgDependent: ContainerOptions === 'Managed' ? 'N/A' : IsOrgDependent ? 'Yes' : 'No',
PackageErrorUsername,
CreatedBy: CreatedById,
Expand Down
12 changes: 6 additions & 6 deletions src/commands/force/package/beta/version/displayancestry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as os from 'os';
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { PackageAncestry, PackageAncestryNodeData } from '@salesforce/packaging';
import { Package, PackageAncestryNodeData } from '@salesforce/packaging';

// Import i18n messages
Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -41,11 +41,11 @@ export class PackageVersionDisplayAncestryCommand extends SfdxCommand {
};

public async run(): Promise<PackageAncestryNodeData | string> {
const packageAncestry = await PackageAncestry.create({
packageId: this.flags.package as string,
project: this.project,
connection: this.hubOrg.getConnection(),
});
const packageAncestry = await Package.getAncestry(
this.flags.package as string,
this.project,
this.hubOrg.getConnection()
);
const jsonProducer = packageAncestry.getJsonProducer();
if (this.flags.dotcode) {
const dotProducer = packageAncestry.getDotProducer();
Expand Down
9 changes: 3 additions & 6 deletions src/commands/force/package/beta/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Messages, SfProject } from '@salesforce/core';
import { CliUx } from '@oclif/core';
import {
getContainerOptions,
getPackageAliasesFromId,
getPackageVersionStrings,
INSTALL_URL_BASE,
Package,
Expand Down Expand Up @@ -122,7 +121,7 @@ export class PackageVersionListCommand extends SfdxCommand {
const ids = [record.Id, record.SubscriberPackageVersionId];
const aliases = [];
ids.forEach((id) => {
const matches = getPackageAliasesFromId(id, project);
const matches = project.getAliasesFromPackageId(id);
if (matches.length > 0) {
aliases.push(matches);
}
Expand Down Expand Up @@ -180,10 +179,8 @@ export class PackageVersionListCommand extends SfdxCommand {
// Table output needs string false to display 'false'
IsPasswordProtected: this.flags.json ? record.IsPasswordProtected : record.IsPasswordProtected.toString(),
IsReleased: this.flags.json ? record.IsReleased : record.IsReleased.toString(),
CreatedDate: record.CreatedDate, // (record.CreatedDate).format('YYYY-MM-DD HH:mm'),
LastModifiedDate: record.LastModifiedDate, // moment(record.LastModifiedDate).format('YYYY-MM-DD HH:mm'),
// CreatedDate: moment(record.CreatedDate).format('YYYY-MM-DD HH:mm'),
// LastModifiedDate: moment(record.LastModifiedDate).format('YYYY-MM-DD HH:mm'),
CreatedDate: new Date(record.CreatedDate).toISOString().replace('T', ' ').substring(0, 16),
LastModifiedDate: new Date(record.LastModifiedDate).toISOString().replace('T', ' ').substring(0, 16),
InstallUrl: INSTALL_URL_BASE.toString() + record.SubscriberPackageVersionId,
CodeCoverage: codeCoverage,
HasPassedCodeCoverageCheck: hasPassedCodeCoverageCheck,
Expand Down
3 changes: 3 additions & 0 deletions test/commands/force/package/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ describe('force:package:install', () => {
}
});

// TODO: It seems that while linking @salesforce/packaging into the plugin
// we cannot stub the library calls of `SfProject.getInstance` e.g. "SfProject, 'getInstance'"
// once the library has been published, the stubs resume to work and this test will pass
it('should print SUCCESS status correctly for package alias', async () => {
// Stubs SfProject.getInstance, SfProject.getSfProjectJson, and SfProjectJson.getContents
// in a way that makes TS happy... all to test package aliases.
Expand Down
2 changes: 1 addition & 1 deletion test/commands/force/package/packageVersion.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import { execCmd, genUniqueString, TestSession } from '@salesforce/cli-plugins-testkit';
import { ConfigAggregator, Org, SfProject } from '@salesforce/core';
import { expect } from 'chai';
import { Duration } from '@salesforce/kit';
import {
PackageAncestryNodeData,
PackageSaveResult,
PackageVersionCreateRequestResult,
PackagingSObjects,
VersionNumber,
} from '@salesforce/packaging';
import { Duration } from '@salesforce/kit';
import { PackageVersionListCommandResult } from '../../../../src/commands/force/package/beta/version/list';

describe('package:version:*', () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,10 @@
shx "^0.3.3"
tslib "^2.2.0"

"@salesforce/packaging@^0.1.18":
version "0.1.18"
resolved "https://registry.yarnpkg.com/@salesforce/packaging/-/packaging-0.1.18.tgz#d76d59611d4b940600a49963a18c71e2ade6088c"
integrity sha512-GaxqayvbA88vtCBMJn8TX+cnrw6jbPMJuQVypOWDcnROGXUEfA4GZJBuf5oAimVnuhGFmXNpbloMx3fat0i1PQ==
"@salesforce/packaging@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@salesforce/packaging/-/packaging-1.0.1.tgz#14b73d9078064ac2ff07b9f319fac034c3f8fdfd"
integrity sha512-KJWGapdEddiUq73/15RQaefzjxi6njYWRcFxM7Dr1ANGdK5nigRkaB3SJzaT1xhOscmZhuob4Gq7y267EIINrg==
dependencies:
"@oclif/core" "^1.19.1"
"@salesforce/core" "^3.31.16"
Expand Down