Skip to content

Commit

Permalink
Merge pull request #146 from salesforcecli/wr/eslintDevScripts
Browse files Browse the repository at this point in the history
fix: apply dev scripts and bump packaging
  • Loading branch information
shetzel authored Nov 4, 2022
2 parents 8c48e72 + 24e4330 commit 569cf9e
Show file tree
Hide file tree
Showing 23 changed files with 661 additions and 862 deletions.
35 changes: 14 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,47 @@
"@salesforce/command": "^5.2.17",
"@salesforce/core": "^3.31.15",
"@salesforce/kit": "^1.7.0",
"@salesforce/packaging": "^0.1.17",
"@salesforce/packaging": "^0.1.18",
"chalk": "^4.1.2",
"tslib": "^2"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^3.1.3",
"@oclif/plugin-version": "^1.1.2",
"@salesforce/cli-plugins-testkit": "^3.2.2",
"@salesforce/dev-config": "^2.1.3",
"@salesforce/dev-scripts": "^1.0.4",
"@salesforce/dev-config": "^3.1.0",
"@salesforce/dev-scripts": "^3.1.0",
"@salesforce/plugin-auth": "^2.2.16",
"@salesforce/plugin-command-reference": "^1.3.20",
"@salesforce/plugin-config": "^1.4.12",
"@salesforce/prettier-config": "^0.0.2",
"@salesforce/ts-sinon": "1.4.1",
"@salesforce/ts-types": "^1.5.20",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"chai": "^4.3.6",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-salesforce": "^0.1.6",
"eslint-config-salesforce": "^1.1.0",
"eslint-config-salesforce-license": "^0.1.6",
"eslint-config-salesforce-typescript": "^0.2.8",
"eslint-config-salesforce-typescript": "^1.1.1",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^35.5.1",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-jsdoc": "^39.3.6",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"mocha": "^8.4.0",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"oclif": "^3.0.1",
"prettier": "^2.4.1",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"shx": "0.3.4",
"sinon": "^11.1.2",
"ts-node": "^10.8.1",
"typescript": "^4.6.4"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"config": {},
"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},
"files": [
"/lib",
Expand Down Expand Up @@ -188,4 +181,4 @@
"publishConfig": {
"access": "public"
}
}
}
8 changes: 7 additions & 1 deletion src/commands/force/package/beta/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ export class Install extends SfdxCommand {

const pkgInstallRequest = await this.subscriberPackageVersion.install(request, installOptions);
this.ux.stopSpinner();
Install.parseStatus(pkgInstallRequest, this.ux, messages, this.org.getUsername(), this.flags.package);
Install.parseStatus(
pkgInstallRequest,
this.ux,
messages,
this.org.getUsername(),
this.flags.package as Optional<string>
);

return pkgInstallRequest;
}
Expand Down
5 changes: 4 additions & 1 deletion src/commands/force/package/beta/install/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class Report extends SfdxCommand {

public async run(): Promise<PackageInstallRequest> {
const connection = this.org.getConnection();
const pkgInstallRequest = await SubscriberPackageVersion.getInstallRequest(this.flags.requestid, connection);
const pkgInstallRequest = await SubscriberPackageVersion.getInstallRequest(
this.flags.requestid as string,
connection
);
InstallCommand.parseStatus(pkgInstallRequest, this.ux, installMsgs, this.org.getUsername());

return pkgInstallRequest;
Expand Down
7 changes: 3 additions & 4 deletions src/commands/force/package/beta/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class PackageListCommand extends SfdxCommand {
IsOrgDependent,
PackageErrorUsername,
CreatedById,
}) => {
return {
}) =>
({
Id,
SubscriberPackageId,
Name,
Expand All @@ -81,8 +81,7 @@ export class PackageListCommand extends SfdxCommand {
IsOrgDependent: ContainerOptions === 'Managed' ? 'N/A' : IsOrgDependent ? 'Yes' : 'No',
PackageErrorUsername,
CreatedBy: CreatedById,
} as Package2Result;
}
} as Package2Result)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/package/beta/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PackageUninstallCommand extends SfdxCommand {
password: undefined,
});

const result = await packageVersion.uninstall(this.flags.wait);
const result = await packageVersion.uninstall(this.flags.wait as Duration);

const arg = result.Status === 'Success' ? [result.SubscriberPackageVersionId] : [result.Id, this.org.getUsername()];
this.ux.log(messages.getMessage(result.Status, arg));
Expand Down
5 changes: 4 additions & 1 deletion src/commands/force/package/beta/version/create/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class PackageVersionCreateReportCommand extends SfdxCommand {
};

public async run(): Promise<PackageVersionCreateRequestResult> {
const result = await PackageVersion.getCreateStatus(this.flags.packagecreaterequestid, this.hubOrg.getConnection());
const result = await PackageVersion.getCreateStatus(
this.flags.packagecreaterequestid as string,
this.hubOrg.getConnection()
);
this.display(result);
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/force/package/beta/version/displayancestry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export class PackageVersionDisplayAncestryCommand extends SfdxCommand {
project: this.project,
connection: this.hubOrg.getConnection(),
});
const jsonProducer = await packageAncestry.getJsonProducer();
const jsonProducer = packageAncestry.getJsonProducer();
if (this.flags.dotcode) {
const dotProducer = await packageAncestry.getDotProducer();
const dotProducer = packageAncestry.getDotProducer();
const dotCodeResult: string = dotProducer.produce() as string;
if (this.flags.json) {
return dotCodeResult;
Expand All @@ -57,11 +57,11 @@ export class PackageVersionDisplayAncestryCommand extends SfdxCommand {
}
} else {
if (packageAncestry.requestedPackageId.startsWith('04t')) {
const paths = await packageAncestry.getLeafPathToRoot(packageAncestry.requestedPackageId);
const paths = packageAncestry.getLeafPathToRoot(packageAncestry.requestedPackageId);
this.ux.log(`${paths[0].map((p) => p.getVersion()).join(' -> ')} (root)`);
this.ux.log();
}
const treeProducer = await packageAncestry.getTreeProducer(!!this.flags.verbose);
const treeProducer = packageAncestry.getTreeProducer(!!this.flags.verbose);
if (!this.flags.json) {
treeProducer.produce();
}
Expand Down
6 changes: 4 additions & 2 deletions src/commands/force/package/beta/version/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class PackageVersionPromoteCommand extends SfdxCommand {
}

// Prompt for confirmation
if (!(await this.ux.confirm(messages.getMessage('packageVersionPromoteConfirm', [this.flags.package])))) {
if (
!(await this.ux.confirm(messages.getMessage('packageVersionPromoteConfirm', [this.flags.package as string])))
) {
return;
}
}
Expand All @@ -59,7 +61,7 @@ export class PackageVersionPromoteCommand extends SfdxCommand {
result = await packageVersion.promote();
result.id = packageVersionData.SubscriberPackageVersionId;
} catch (e) {
const err = SfError.wrap(e);
const err = SfError.wrap(e as Error);
if (err.name === 'DUPLICATE_VALUE' && err.message.includes('previously released')) {
err.message = messages.getMessage('previouslyReleasedMessage');
err.actions = [messages.getMessage('previouslyReleasedAction')];
Expand Down
13 changes: 6 additions & 7 deletions src/commands/force/package/beta/version/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class PackageVersionReportCommand extends SfdxCommand {
project: this.project,
idOrAlias: this.flags.package as string,
});
const results = await packageVersion.report(this.flags.verbose);
const results = await packageVersion.report(this.flags.verbose as boolean);
const massagedResults = this.massageResultsForDisplay(results);
this.display(massagedResults);
return massagedResults;
Expand Down Expand Up @@ -157,12 +157,10 @@ export class PackageVersionReportCommand extends SfdxCommand {
codeCovStr =
'The code coverage details are too large to display. To request code coverage details for this package version, log a case in the Salesforce Partner Community.';
} else {
displayCoverageRecords = coverageData.slice(0, maximumNumClasses).map((coverageDatum) => {
return {
key: coverageDatum.className,
value: `${coverageDatum.codeCoveragePercentage}%`,
};
});
displayCoverageRecords = coverageData.slice(0, maximumNumClasses).map((coverageDatum) => ({
key: coverageDatum.className,
value: `${coverageDatum.codeCoveragePercentage}%`,
}));
this.haveCodeCoverageData = displayCoverageRecords.length > 0;
}
}
Expand Down Expand Up @@ -192,6 +190,7 @@ export class PackageVersionReportCommand extends SfdxCommand {
}
}

// eslint-disable-next-line class-methods-use-this
private massageResultsForDisplay(results: PackageVersionReportResult): PackageVersionReportResultModified {
const record = JSON.parse(JSON.stringify(results)) as PackageVersionReportResultModified;
record.Version = [record.MajorVersion, record.MinorVersion, record.PatchVersion, record.BuildNumber].join('.');
Expand Down
3 changes: 2 additions & 1 deletion src/commands/force/package1/beta/version/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Package1VersionCreateCommand extends SfdxCommand {
};

public async run(): Promise<PackageUploadRequest> {
const version = this.parseVersion(this.flags.version);
const version = this.parseVersion(this.flags.version as string);
if (this.flags.wait) {
// if we're waiting for the request, set up the listener
Lifecycle.getInstance().on(
Expand Down Expand Up @@ -108,6 +108,7 @@ export class Package1VersionCreateCommand extends SfdxCommand {
return result;
}

// eslint-disable-next-line class-methods-use-this
private parseVersion(versionString: string): { major: number; minor: number } {
const versions = versionString?.split('.');
if (!versions) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/package1/beta/version/create/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Package1VersionCreateGetCommand extends SfdxCommand {
};

public async run(): Promise<PackagingSObjects.PackageUploadRequest> {
const result = await Package1Version.getCreateStatus(this.org.getConnection(), this.flags.requestid);
const result = await Package1Version.getCreateStatus(this.org.getConnection(), this.flags.requestid as string);

if (result.Status === 'ERROR') {
// toolbelt was accessing request.Errors.errors, I'm unsure about this type, but was unable to reproduce an error
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/package1/beta/version/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Package1VersionDisplayCommand extends SfdxCommand {
};

public async run(): Promise<Package1Display[]> {
const pv1 = new Package1Version(this.org.getConnection(), this.flags.packageversionid);
const pv1 = new Package1Version(this.org.getConnection(), this.flags.packageversionid as string);
const results = (await pv1.getPackageVersion()).map((result) => ({
MetadataPackageVersionId: result.Id,
MetadataPackageId: result.MetadataPackageId,
Expand Down
18 changes: 10 additions & 8 deletions src/commands/force/package1/beta/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export class Package1VersionListCommand extends SfdxCommand {
};

public async run(): Promise<Package1Display[]> {
const result = (await Package1Version.list(this.org.getConnection(), this.flags.packageid)).map((record) => ({
MetadataPackageVersionId: record.Id,
MetadataPackageId: record.MetadataPackageId,
Name: record.Name,
ReleaseState: record.ReleaseState,
Version: `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}`,
BuildNumber: record.BuildNumber,
}));
const result = (await Package1Version.list(this.org.getConnection(), this.flags.packageid as string)).map(
(record) => ({
MetadataPackageVersionId: record.Id,
MetadataPackageId: record.MetadataPackageId,
Name: record.Name,
ReleaseState: record.ReleaseState,
Version: `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}`,
BuildNumber: record.BuildNumber,
})
);

if (result.length) {
this.ux.table(result, {
Expand Down
4 changes: 2 additions & 2 deletions test/commands/force/package/install.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ describe('package install', () => {
await session?.clean();
});

it('should install ElectronBranding package with polling', function () {
it('should install ElectronBranding package with polling', () => {
const command = 'force:package:beta:install -p 04t6A000002zgKSQAY -w 20';
const output = execCmd(command, { ensureExitCode: 0, timeout: Duration.minutes(20).milliseconds }).shellOutput
.stdout;
expect(output).to.contain('Successfully installed package');
});

it('should install DFXP Escape Room package (async) and report', function () {
it('should install DFXP Escape Room package (async) and report', () => {
const installCommand = 'force:package:beta:install -p 04t6A000002zgKSQAY --json';
const installJson = execCmd<PackageInstallRequest>(installCommand, { ensureExitCode: 0 }).jsonOutput.result;
expect(installJson).to.have.property('Status', 'IN_PROGRESS');
Expand Down
3 changes: 1 addition & 2 deletions test/commands/force/package/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { TestContext } from '@salesforce/core/lib/testSetup';
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
import { Config } from '@oclif/core';
import { expect } from 'chai';
import { SubscriberPackageVersion, PackageEvents, PackagingSObjects } from '@salesforce/packaging';
import { PackageEvents, PackagingSObjects, SubscriberPackageVersion } from '@salesforce/packaging';
import { Result } from '@salesforce/command';
import { Install } from '../../../../src/commands/force/package/beta/install';

import InstallValidationStatus = PackagingSObjects.InstallValidationStatus;

const myPackageVersion04t = '04t6A000002zgKSQAY';
Expand Down
12 changes: 6 additions & 6 deletions test/commands/force/package/packageCreateAndDelete.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ describe('package create/update/delete', () => {
before(async () => {
pkgName = `test-pkg-${Date.now()}`;
});
it('should create a package - human readable results', function () {
it('should create a package - human readable results', () => {
const command = `force:package:beta:create -n ${pkgName} -v ${session.hubOrg.username} -t Unlocked -r ./force-app`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.contain('=== Ids');
expect(output).to.match(/Package Id\s+?0Ho/);
});
it('should update a package - human readable results', function () {
it('should update a package - human readable results', () => {
const command = `force:package:beta:update --package ${pkgName} --description "My new description" -v ${session.hubOrg.username}`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.match(/Successfully updated the package\.\s+0Ho/);
});
it('should delete a package - human readable results', function () {
it('should delete a package - human readable results', () => {
const command = `force:package:beta:delete -p ${pkgName} -v ${session.hubOrg.username} --noprompt`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.contain('Successfully deleted the package. 0Ho');
Expand All @@ -46,21 +46,21 @@ describe('package create/update/delete', () => {
before(async () => {
pkgName = `test-pkg-${Date.now()}`;
});
it('should create a package - json results', function () {
it('should create a package - json results', () => {
const command = `force:package:beta:create -n ${pkgName} -v ${session.hubOrg.username} -t Unlocked -r ./force-app --json`;
const output = execCmd<{ Id: string }>(command, { ensureExitCode: 0 }).jsonOutput;
expect(output.status).to.equal(0);
expect(output.result).to.have.property('Id');
expect(output.result.Id).to.match(/0Ho.{12,15}/);
});
it('should update a package - json results', function () {
it('should update a package - json results', () => {
const command = `force:package:beta:update --package ${pkgName} --description "My new description" -v ${session.hubOrg.username} --json`;
const output = execCmd<{ id: string }>(command, { ensureExitCode: 0 }).jsonOutput;
expect(output.status).to.equal(0);
expect(output.result).to.have.property('id');
expect(output.result.id).to.match(/0Ho.{12,15}/);
});
it('should delete a package - json results', function () {
it('should delete a package - json results', () => {
const command = `force:package:beta:delete -p ${pkgName} -v ${session.hubOrg.username} --json`;
const output = execCmd<{ id: string; success: boolean; errors: [] }>(command, { ensureExitCode: 0 }).jsonOutput;
expect(output.result.id).to.match(/0Ho.{12,15}/);
Expand Down
6 changes: 3 additions & 3 deletions test/commands/force/package/packageList.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ describe('package list', () => {
after(async () => {
await session?.clean();
});
it('should list packages in dev hub - human readable results', function () {
it('should list packages in dev hub - human readable results', () => {
const command = `force:package:beta:list -v ${session.hubOrg.username}`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.contain('=== Packages');
expect(output).to.match(/Namespace Prefix\s+?Name\s+?Id\s+?Alias\s+?Description\s+?Type/);
});
it('should list packages in dev hub - verbose human readable results', function () {
it('should list packages in dev hub - verbose human readable results', () => {
const command = `force:package:beta:list -v ${session.hubOrg.username} --verbose`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.contain('=== Packages');
expect(output).to.match(
/Namespace Prefix\s+?Name\s+?Id\s+?Alias\s+?Description\s+?Type\s+?Subscriber Package Id\s+?Converted From Package Id\s+?Org-Dependent Unlocked Package\s+?Error Notification Username\s+?Created By/
);
});
it('should list packages in dev hub - json results', function () {
it('should list packages in dev hub - json results', () => {
const command = `force:package:beta:list -v ${session.hubOrg.username} --json`;
const output = execCmd<{ [key: string]: unknown }>(command, { ensureExitCode: 0 }).jsonOutput;
const keys = [
Expand Down
Loading

0 comments on commit 569cf9e

Please sign in to comment.