Skip to content

Commit 48a7b8c

Browse files
authored
fix: nullish-linter (#1134)
* chore: dep bump * fix: no nullish in template literals * chore: lockfile
1 parent 02c2009 commit 48a7b8c

File tree

8 files changed

+54
-54
lines changed

8 files changed

+54
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"moment": "^2.30.1",
2626
"oclif": "^4.14.6",
2727
"ts-node": "^10.9.2",
28-
"typescript": "^5.4.5"
28+
"typescript": "^5.5.3"
2929
},
3030
"engines": {
3131
"node": ">=18.0.0"

src/commands/force/org/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ export class Create extends SfCommand<CreateResult> {
295295

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

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

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

src/commands/org/open.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,7 @@ export class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
115115
await new SfdcUrl(url).checkLightningDomain();
116116
this.spinner.stop();
117117
} catch (err) {
118-
if (err instanceof Error) {
119-
if (err.message.includes('timeout')) {
120-
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.[1]}.lightning.force.com`;
121-
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
122-
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
123-
const logger = await Logger.child(this.constructor.name);
124-
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
125-
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
126-
}
127-
throw SfError.wrap(err);
128-
}
129-
throw err;
118+
handleDomainError(err, url, env);
130119
}
131120

132121
// create a local html file that contains the POST stuff.
@@ -165,16 +154,18 @@ export type OrgOpenOutput = {
165154
url: string;
166155
username: string;
167156
orgId: string;
168-
}
157+
};
169158

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

173162
const buildFrontdoorUrl = async (org: Org, conn: Connection): Promise<string> => {
174163
await org.refreshAuth(); // we need a live accessToken for the frontdoor url
175164
const accessToken = conn.accessToken;
176-
const instanceUrl = org.getField<string>(Org.Fields.INSTANCE_URL);
177-
const instanceUrlClean = instanceUrl.replace(/\/$/, '');
165+
if (!accessToken) {
166+
throw new SfError('NoAccessToken', 'NoAccessToken');
167+
}
168+
const instanceUrlClean = org.getField<string>(Org.Fields.INSTANCE_URL).replace(/\/$/, '');
178169
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
179170
};
180171

@@ -241,3 +232,22 @@ const getFileContents = (
241232
</form>
242233
</body>
243234
</html>`;
235+
236+
const handleDomainError = (err: unknown, url: string, env: Env): string => {
237+
if (err instanceof Error) {
238+
if (err.message.includes('timeout')) {
239+
const host = /https?:\/\/([^.]*)/.exec(url)?.[1];
240+
if (!host) {
241+
throw new SfError('InvalidUrl', 'InvalidUrl');
242+
}
243+
const domain = `https://${host}.lightning.force.com`;
244+
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
245+
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
246+
const logger = Logger.childFromRoot('org:open');
247+
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
248+
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
249+
}
250+
throw SfError.wrap(err);
251+
}
252+
throw err;
253+
};

src/commands/org/resume/sandbox.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const getSandboxProcessObject = async (
236236
sandboxName?: string,
237237
jobId?: string
238238
): Promise<SandboxProcessObject> => {
239-
const where = jobId ? `Id='${jobId}'` : `SandboxName='${sandboxName}'`;
239+
const where = getWhere(sandboxName, jobId);
240240
const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE ${where} AND Status != 'D'`;
241241
try {
242242
return await prodOrg.getConnection().singleRecordQuery(queryStr, {
@@ -246,3 +246,9 @@ const getSandboxProcessObject = async (
246246
throw messages.createError('error.NoSandboxRequestFound');
247247
}
248248
};
249+
250+
const getWhere = (sandboxName?: string, jobId?: string): string => {
251+
if (jobId) return `Id='${jobId}'`;
252+
if (sandboxName) return `SandboxName='${sandboxName}'`;
253+
throw new SfError('There must be a sandbox name or job id to query for the sandbox process object');
254+
};

src/shared/orgListUtil.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ export class OrgListUtil {
155155
return auth;
156156
}
157157
const orgId = auth.getFields().orgId;
158-
158+
if (!orgId) {
159+
throw new SfError('No orgId found in auth file');
160+
}
159161
const orgFileName = `${orgId}.json`;
160162
// 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
161163
if (orgId && !orgFileNames.includes(orgFileName)) {
@@ -220,7 +222,7 @@ export class OrgListUtil {
220222
);
221223

222224
return {
223-
scratchOrgs: results.filter((result) => 'expirationDate' in result) as ExtendedAuthFieldsScratch[],
225+
scratchOrgs: results.filter((result) => 'expirationDate' in result),
224226
nonScratchOrgs: results.filter((result) => !('expirationDate' in result)),
225227
};
226228
}

src/shared/sandboxProgress.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ export class SandboxProgress extends StagedProgress<SandboxStatusData> {
7777
return [
7878
withClock && this.statusData
7979
? `${getClockForSeconds(this.statusData.sandboxProgress.remainingWaitTime)} until timeout. ${
80-
this.statusData.sandboxProgress.percentComplete
80+
this.statusData.sandboxProgress.percentComplete ?? 0
8181
}%`
8282
: undefined,
8383
table,
8484
'---------------------',
85-
`Sandbox ${this.action} Stages`,
85+
`Sandbox ${this.action ?? ''} Stages`,
8686
this.formatStages(),
8787
]
8888
.filter(isDefined)
@@ -113,7 +113,7 @@ export const getTableDataFromProcessObj = (
113113
{ key: 'LicenseType', value: sandboxProcessObj.LicenseType },
114114
{ key: 'SandboxInfoId', value: sandboxProcessObj.SandboxInfoId },
115115
{ key: 'Created Date', value: sandboxProcessObj.CreatedDate },
116-
{ key: 'CopyProgress', value: `${sandboxProcessObj.CopyProgress}%` },
116+
{ key: 'CopyProgress', value: `${sandboxProcessObj.CopyProgress ?? 0}%` },
117117
...(sandboxProcessObj.SourceId ? [{ key: 'SourceId', value: sandboxProcessObj.SourceId }] : []),
118118
...(sandboxProcessObj.SandboxOrganization
119119
? [{ key: 'SandboxOrg', value: sandboxProcessObj.SandboxOrganization }]

src/shared/sandboxReporter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export class SandboxReporter {
1515
const waitTimeMsg = `Sleeping ${interval} seconds. Will wait ${waitTime} more before timing out.`;
1616
const sandboxIdentifierMsg = `${sandboxProcessObj.SandboxName}(${sandboxProcessObj.Id})`;
1717
const waitingOnAuthMessage: string = waitingOnAuth ? ', waiting on JWT auth' : '';
18-
const completionMessage = `(${sandboxProcessObj.CopyProgress}% completed${waitingOnAuthMessage})`;
18+
const completionMessage = sandboxProcessObj.CopyProgress
19+
? `(${sandboxProcessObj.CopyProgress}% completed${waitingOnAuthMessage})`
20+
: '';
1921

2022
return `Sandbox request ${sandboxIdentifierMsg} is ${sandboxProcessObj.Status} ${completionMessage}. ${waitTimeMsg}`;
2123
}

yarn.lock

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7040,16 +7040,7 @@ srcset@^5.0.0:
70407040
resolved "https://registry.yarnpkg.com/srcset/-/srcset-5.0.1.tgz#e660a728f195419e4afa95121099bc9efb7a1e36"
70417041
integrity sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw==
70427042

7043-
"string-width-cjs@npm:string-width@^4.2.0":
7044-
version "4.2.3"
7045-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
7046-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
7047-
dependencies:
7048-
emoji-regex "^8.0.0"
7049-
is-fullwidth-code-point "^3.0.0"
7050-
strip-ansi "^6.0.1"
7051-
7052-
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
7043+
"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:
70537044
version "4.2.3"
70547045
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
70557046
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -7117,14 +7108,7 @@ string_decoder@~1.1.1:
71177108
dependencies:
71187109
safe-buffer "~5.1.0"
71197110

7120-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
7121-
version "6.0.1"
7122-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
7123-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
7124-
dependencies:
7125-
ansi-regex "^5.0.1"
7126-
7127-
[email protected], strip-ansi@^6.0.0, strip-ansi@^6.0.1:
7111+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", [email protected], strip-ansi@^6.0.0, strip-ansi@^6.0.1:
71287112
version "6.0.1"
71297113
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
71307114
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -7460,7 +7444,12 @@ typedoc@^0.26.5:
74607444
shiki "^1.9.1"
74617445
yaml "^2.4.5"
74627446

7463-
"typescript@^4.6.4 || ^5.2.2", typescript@^5.4.3, typescript@^5.4.5, typescript@~5.4.2:
7447+
"typescript@^4.6.4 || ^5.2.2", typescript@^5.4.3, typescript@^5.5.3:
7448+
version "5.5.3"
7449+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
7450+
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
7451+
7452+
typescript@~5.4.2:
74647453
version "5.4.5"
74657454
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
74667455
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
@@ -7669,7 +7658,7 @@ workerpool@^6.5.1:
76697658
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
76707659
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==
76717660

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

7690-
wrap-ansi@^7.0.0:
7691-
version "7.0.0"
7692-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
7693-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
7694-
dependencies:
7695-
ansi-styles "^4.0.0"
7696-
string-width "^4.1.0"
7697-
strip-ansi "^6.0.0"
7698-
76997679
wrap-ansi@^8.1.0:
77007680
version "8.1.0"
77017681
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)