Skip to content

Commit

Permalink
fix: nullish-linter (#1134)
Browse files Browse the repository at this point in the history
* chore: dep bump

* fix: no nullish in template literals

* chore: lockfile
  • Loading branch information
mshanemc authored Jul 23, 2024
1 parent 02c2009 commit 48a7b8c
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"moment": "^2.30.1",
"oclif": "^4.14.6",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
"typescript": "^5.5.3"
},
"engines": {
"node": ">=18.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/force/org/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ export class Create extends SfCommand<CreateResult> {

await Lifecycle.getInstance().emit('scratchOrgInfo', scratchOrgInfo);

this.logger.debug(`orgConfig.loginUrl: ${authFields?.loginUrl}`);
this.logger.debug(`orgConfig.instanceUrl: ${authFields?.instanceUrl}`);
this.logger.debug(`orgConfig.loginUrl: ${authFields?.loginUrl ?? '<not found>'}`);
this.logger.debug(`orgConfig.instanceUrl: ${authFields?.instanceUrl ?? '<not found>'}`);

this.log(messages.getMessage('scratchOrgCreateSuccess', [authFields?.orgId, username]));

Expand Down
40 changes: 25 additions & 15 deletions src/commands/org/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,7 @@ export class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
await new SfdcUrl(url).checkLightningDomain();
this.spinner.stop();
} catch (err) {
if (err instanceof Error) {
if (err.message.includes('timeout')) {
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.[1]}.lightning.force.com`;
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
const logger = await Logger.child(this.constructor.name);
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
}
throw SfError.wrap(err);
}
throw err;
handleDomainError(err, url, env);
}

// create a local html file that contains the POST stuff.
Expand Down Expand Up @@ -165,16 +154,18 @@ export type OrgOpenOutput = {
url: string;
username: string;
orgId: string;
}
};

const fileCleanup = (tempFilePath: string): void =>
fs.rmSync(tempFilePath, { force: true, maxRetries: 3, recursive: true });

const buildFrontdoorUrl = async (org: Org, conn: Connection): Promise<string> => {
await org.refreshAuth(); // we need a live accessToken for the frontdoor url
const accessToken = conn.accessToken;
const instanceUrl = org.getField<string>(Org.Fields.INSTANCE_URL);
const instanceUrlClean = instanceUrl.replace(/\/$/, '');
if (!accessToken) {
throw new SfError('NoAccessToken', 'NoAccessToken');
}
const instanceUrlClean = org.getField<string>(Org.Fields.INSTANCE_URL).replace(/\/$/, '');
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
};

Expand Down Expand Up @@ -241,3 +232,22 @@ const getFileContents = (
</form>
</body>
</html>`;

const handleDomainError = (err: unknown, url: string, env: Env): string => {
if (err instanceof Error) {
if (err.message.includes('timeout')) {
const host = /https?:\/\/([^.]*)/.exec(url)?.[1];
if (!host) {
throw new SfError('InvalidUrl', 'InvalidUrl');
}
const domain = `https://${host}.lightning.force.com`;
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
const logger = Logger.childFromRoot('org:open');
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
}
throw SfError.wrap(err);
}
throw err;
};
8 changes: 7 additions & 1 deletion src/commands/org/resume/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const getSandboxProcessObject = async (
sandboxName?: string,
jobId?: string
): Promise<SandboxProcessObject> => {
const where = jobId ? `Id='${jobId}'` : `SandboxName='${sandboxName}'`;
const where = getWhere(sandboxName, jobId);
const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE ${where} AND Status != 'D'`;
try {
return await prodOrg.getConnection().singleRecordQuery(queryStr, {
Expand All @@ -246,3 +246,9 @@ const getSandboxProcessObject = async (
throw messages.createError('error.NoSandboxRequestFound');
}
};

const getWhere = (sandboxName?: string, jobId?: string): string => {
if (jobId) return `Id='${jobId}'`;
if (sandboxName) return `SandboxName='${sandboxName}'`;
throw new SfError('There must be a sandbox name or job id to query for the sandbox process object');
};
6 changes: 4 additions & 2 deletions src/shared/orgListUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export class OrgListUtil {
return auth;
}
const orgId = auth.getFields().orgId;

if (!orgId) {
throw new SfError('No orgId found in auth file');
}
const orgFileName = `${orgId}.json`;
// if userId, it could be created from password:generate command. If <orgId>.json doesn't exist, it's also not a secondary user auth file
if (orgId && !orgFileNames.includes(orgFileName)) {
Expand Down Expand Up @@ -220,7 +222,7 @@ export class OrgListUtil {
);

return {
scratchOrgs: results.filter((result) => 'expirationDate' in result) as ExtendedAuthFieldsScratch[],
scratchOrgs: results.filter((result) => 'expirationDate' in result),
nonScratchOrgs: results.filter((result) => !('expirationDate' in result)),
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/sandboxProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export class SandboxProgress extends StagedProgress<SandboxStatusData> {
return [
withClock && this.statusData
? `${getClockForSeconds(this.statusData.sandboxProgress.remainingWaitTime)} until timeout. ${
this.statusData.sandboxProgress.percentComplete
this.statusData.sandboxProgress.percentComplete ?? 0
}%`
: undefined,
table,
'---------------------',
`Sandbox ${this.action} Stages`,
`Sandbox ${this.action ?? ''} Stages`,
this.formatStages(),
]
.filter(isDefined)
Expand Down Expand Up @@ -113,7 +113,7 @@ export const getTableDataFromProcessObj = (
{ key: 'LicenseType', value: sandboxProcessObj.LicenseType },
{ key: 'SandboxInfoId', value: sandboxProcessObj.SandboxInfoId },
{ key: 'Created Date', value: sandboxProcessObj.CreatedDate },
{ key: 'CopyProgress', value: `${sandboxProcessObj.CopyProgress}%` },
{ key: 'CopyProgress', value: `${sandboxProcessObj.CopyProgress ?? 0}%` },
...(sandboxProcessObj.SourceId ? [{ key: 'SourceId', value: sandboxProcessObj.SourceId }] : []),
...(sandboxProcessObj.SandboxOrganization
? [{ key: 'SandboxOrg', value: sandboxProcessObj.SandboxOrganization }]
Expand Down
4 changes: 3 additions & 1 deletion src/shared/sandboxReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class SandboxReporter {
const waitTimeMsg = `Sleeping ${interval} seconds. Will wait ${waitTime} more before timing out.`;
const sandboxIdentifierMsg = `${sandboxProcessObj.SandboxName}(${sandboxProcessObj.Id})`;
const waitingOnAuthMessage: string = waitingOnAuth ? ', waiting on JWT auth' : '';
const completionMessage = `(${sandboxProcessObj.CopyProgress}% completed${waitingOnAuthMessage})`;
const completionMessage = sandboxProcessObj.CopyProgress
? `(${sandboxProcessObj.CopyProgress}% completed${waitingOnAuthMessage})`
: '';

return `Sandbox request ${sandboxIdentifierMsg} is ${sandboxProcessObj.Status} ${completionMessage}. ${waitTimeMsg}`;
}
Expand Down
38 changes: 9 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7040,16 +7040,7 @@ srcset@^5.0.0:
resolved "https://registry.yarnpkg.com/srcset/-/srcset-5.0.1.tgz#e660a728f195419e4afa95121099bc9efb7a1e36"
integrity sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -7117,14 +7108,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

[email protected], strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", [email protected], strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -7460,7 +7444,12 @@ typedoc@^0.26.5:
shiki "^1.9.1"
yaml "^2.4.5"

"typescript@^4.6.4 || ^5.2.2", typescript@^5.4.3, typescript@^5.4.5, typescript@~5.4.2:
"typescript@^4.6.4 || ^5.2.2", typescript@^5.4.3, typescript@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==

typescript@~5.4.2:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
Expand Down Expand Up @@ -7669,7 +7658,7 @@ workerpool@^6.5.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -7687,15 +7676,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 48a7b8c

Please sign in to comment.