-
Notifications
You must be signed in to change notification settings - Fork 16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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>'}'.` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logs get a more descriptive indicator of what's missing from where |
||
); | ||
await pkgUtils.zipDir(seedMetadataFolder, seedMetadataZipFile); | ||
} | ||
|
||
await settingsGenerator.createDeploy(); | ||
await settingsGenerator.createDeployPackageContents(apiVersion); | ||
await pkgUtils.zipDir( | ||
`${settingsGenerator.getDestinationPath()}${path.sep}${settingsGenerator.getShapeDirName()}`, | ||
`${settingsGenerator.getDestinationPath() ?? ''}${path.sep}${settingsGenerator.getShapeDirName()}`, | ||
settingsZipFile | ||
); | ||
|
||
const shapeDirectory = `${settingsGenerator.getDestinationPath()}${path.sep}${settingsGenerator.getShapeDirName()}`; | ||
const shapeDirectory = `${settingsGenerator.getDestinationPath() ?? ''}${ | ||
path.sep | ||
}${settingsGenerator.getShapeDirName()}`; | ||
const currentPackageXml = await fs.promises.readFile(path.join(shapeDirectory, 'package.xml'), 'utf8'); | ||
await fs.promises.writeFile(path.join(packageVersMetadataFolder, 'package.xml'), currentPackageXml, 'utf-8'); | ||
// Zip the packageVersMetadataFolder folder and put the zip in {packageVersBlobDirectory}/package.zip | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ export class PackageVersion { | |
frequency: Duration.seconds(0), | ||
timeout: Duration.seconds(0), | ||
} | ||
): Promise<Partial<PackageVersionCreateRequestResult>> { | ||
): Promise<PackageVersionCreateRequestResult> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the function called at the bottom (byId) claims its return type is Other consumers of byId also return a the very loose |
||
const pvc = new PackageVersionCreate({ ...options }); | ||
const createResult = await pvc.createPackageVersion(); | ||
|
||
|
@@ -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')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the conditional didn't need to be checked for every field |
||
return parseInt(connection.getApiVersion(), 10) > 60 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comparing strings via |
||
? Package2VersionFields | ||
: Package2VersionFields.filter((field) => field !== 'ValidatedAsync'); | ||
} | ||
|
||
/** | ||
|
@@ -460,7 +461,7 @@ export class PackageVersion { | |
if (!this.packageType) { | ||
this.packageType = ( | ||
await this.connection.singleRecordQuery<Package2>( | ||
`select ContainerOptions from Package2 where Id = '${await this.getPackageId()}' limit 1`, | ||
`select ContainerOptions from Package2 where Id = '${(await this.getPackageId()) ?? ''}' limit 1`, | ||
{ tooling: true } | ||
) | ||
).ContainerOptions; | ||
|
@@ -476,34 +477,29 @@ export class PackageVersion { | |
* @returns Package2Version | ||
*/ | ||
public async getData(force = false): Promise<Package2Version> | never { | ||
let is05i = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope |
||
if (!this.data || force) { | ||
// validate ID | ||
if (this.id.startsWith('04t')) { | ||
validateId(BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID, this.id); | ||
is05i = false; | ||
} else if (this.id.startsWith('05i')) { | ||
validateId(BY_LABEL.PACKAGE_VERSION_ID, this.id); | ||
is05i = true; | ||
} else { | ||
throw messages.createError('errorInvalidPackageVersionId', [this.options.idOrAlias]); | ||
} | ||
let queryConfig: { id: string; clause: string; label1: string; label2: string }; | ||
if (is05i) { | ||
queryConfig = { | ||
id: this.id, | ||
clause: `Id = '${this.id}'`, | ||
label1: BY_LABEL.PACKAGE_VERSION_ID.label, | ||
label2: BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label, | ||
}; | ||
} else { | ||
queryConfig = { | ||
id: this.id, | ||
clause: `SubscriberPackageVersionId = '${this.id}'`, | ||
label1: BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label, | ||
label2: BY_LABEL.PACKAGE_VERSION_ID.label, | ||
}; | ||
} | ||
const queryConfig: { id: string; clause: string; label1: string; label2: string } = this.id.startsWith('05i') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const > let |
||
? { | ||
id: this.id, | ||
clause: `Id = '${this.id}'`, | ||
label1: BY_LABEL.PACKAGE_VERSION_ID.label, | ||
label2: BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label, | ||
} | ||
: { | ||
id: this.id, | ||
clause: `SubscriberPackageVersionId = '${this.id}'`, | ||
label1: BY_LABEL.SUBSCRIBER_PACKAGE_VERSION_ID.label, | ||
label2: BY_LABEL.PACKAGE_VERSION_ID.label, | ||
}; | ||
|
||
const allFields = PackageVersion.getPackage2VersionFields(this.connection).toString(); | ||
const query = `SELECT ${allFields} FROM Package2Version WHERE ${queryConfig.clause} LIMIT 1`; | ||
try { | ||
|
@@ -633,7 +629,9 @@ export class PackageVersion { | |
PatchVersion: string; | ||
BuildNumber: string; | ||
}>( | ||
`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${results.SubscriberPackageVersionId}'` | ||
`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${ | ||
results.SubscriberPackageVersionId ?? '' | ||
}'` | ||
) | ||
).records[0]; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { pipeline as cbPipeline } from 'node:stream'; | |
import util, { promisify } from 'node:util'; | ||
import { randomBytes } from 'node:crypto'; | ||
import { Connection, Logger, Messages, ScratchOrgInfo, SfdcUrl, SfError, SfProject } from '@salesforce/core'; | ||
import { isNumber, isString, Many, Nullable, Optional } from '@salesforce/ts-types'; | ||
import { isNumber, isString, Many, Optional } from '@salesforce/ts-types'; | ||
import type { SaveError } from '@jsforce/jsforce-node'; | ||
import { Duration, ensureArray } from '@salesforce/kit'; | ||
import globby from 'globby'; | ||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. every consumer was passing a string |
||
return key.replace(/\\/g, '\\\\').replace(/'/g, "\\'"); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
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