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: no nullish in template literal #627

Merged
merged 3 commits into from
Jul 30, 2024
Merged

fix: no nullish in template literal #627

merged 3 commits into from
Jul 30, 2024

Conversation

svc-cli-bot
Copy link
Contributor

@svc-cli-bot svc-cli-bot commented Jul 28, 2024

updates the deps for all the other PRs.
applies our linter rule ( no nullish in template literals)
reduce let

@@ -320,7 +320,9 @@ export class PackageAncestry extends AsyncCreatable<PackageAncestryOptions> {
// Check to see if the package is an unlocked package
// if so, throw and error since ancestry only applies to managed packages
await this.validatePackageType();
const normalQuery = `${SELECT_PACKAGE_VERSION} WHERE AncestorId = NULL AND Package2Id = '${this.requestedPackageId}' ${releasedOnlyFilter}`;
const normalQuery = `${SELECT_PACKAGE_VERSION} WHERE AncestorId = NULL AND Package2Id = '${
this.requestedPackageId ?? ''
Copy link
Contributor

@mshanemc mshanemc Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where queries and consts are being built, I preserved the existing behavior (with `?? '') to let the server handle the missing value like it currently would

@@ -205,19 +205,21 @@ export async function createPackageVersionCreateRequest(
if (hasSeedMetadata) {
// Zip the seedMetadataFolder folder and put the zip in {packageVersBlobDirectory}/{seedMetadataZipFile}
Logger.childFromRoot('packageConvert:pollForStatusWithInterval').debug(
`Including metadata found in '${context.seedmetadata}'.`
`Including metadata found in '${context.seedmetadata ?? '<undefined seedmetadata>'}'.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logs get a more descriptive indicator of what's missing from where

@@ -145,7 +145,7 @@ export class PackageVersion {
frequency: Duration.seconds(0),
timeout: Duration.seconds(0),
}
): Promise<Partial<PackageVersionCreateRequestResult>> {
): Promise<PackageVersionCreateRequestResult> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function called at the bottom (byId) claims its return type is PackageVersionCreateRequestResult.

Other consumers of byId also return a PackageVersionCreateRequestResult so I used that.

the very loose Partial would have forced lots of undefined checks.

@@ -411,8 +411,9 @@ export class PackageVersion {
}

private static getPackage2VersionFields(connection: Connection): string[] {
const apiVersion = connection.getApiVersion();
return Package2VersionFields.filter((field) => (apiVersion > '60.0' ? true : field !== 'ValidatedAsync'));
return parseInt(connection.getApiVersion(), 10) > 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparing strings via > works fine until we get to 100, after which 100.0 < 99.0 so use numbers when comparing numbers

@@ -411,8 +411,9 @@ export class PackageVersion {
}

private static getPackage2VersionFields(connection: Connection): string[] {
const apiVersion = connection.getApiVersion();
return Package2VersionFields.filter((field) => (apiVersion > '60.0' ? true : field !== 'ValidatedAsync'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the conditional didn't need to be checked for every field

@@ -476,34 +477,29 @@ export class PackageVersion {
* @returns Package2Version
*/
public async getData(force = false): Promise<Package2Version> | never {
let is05i = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

label2: BY_LABEL.PACKAGE_VERSION_ID.label,
};
}
const queryConfig: { id: string; clause: string; label1: string; label2: string } = this.id.startsWith('05i')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const > let

@@ -202,8 +202,8 @@ export async function getPackageVersionId(versionId: string, connection: Connect
});
}

export function escapeInstallationKey(key?: string): Nullable<string> {
return key ? key.replace(/\\/g, '\\\\').replace(/'/g, "\\'") : null;
export function escapeInstallationKey(key: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every consumer was passing a string

@mshanemc mshanemc changed the title refactor: devScripts update fix: no nullish in template literal Jul 30, 2024
@mshanemc mshanemc merged commit 1009ec9 into main Jul 30, 2024
15 of 17 checks passed
@mshanemc mshanemc deleted the devScripts2024-07-28 branch July 30, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants