Skip to content

Commit

Permalink
fix(perf): perf tweaks, semver is a dep (#918)
Browse files Browse the repository at this point in the history
* fix: semver is a real dep

* fix(perf): cleaner module isolation

* ci: retries on yarn install
  • Loading branch information
mshanemc authored Aug 31, 2023
1 parent 09b8144 commit 5636083
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- run: yarn build
- run: npm run test:perf | tee test/perf/output.txt

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"pino-abstract-transport": "^1.0.0",
"pino-pretty": "^10.2.0",
"proper-lockfile": "^4.1.2",
"semver": "^7.5.4",
"ts-retry-promise": "^0.7.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/util/checkLightningDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import { URL } from 'url';
import { Env, Duration } from '@salesforce/kit';
import { MyDomainResolver } from '../status/myDomainResolver';
import { isInternalUrl } from './sfdc';
import { SfdcUrl } from './sfdcUrl';

export default async function checkLightningDomain(url: string): Promise<boolean> {
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.slice(1, 2).pop()}.lightning.force.com`;
const quantity = new Env().getNumber('SFDX_DOMAIN_RETRY', 240) ?? 0;
const timeout = new Duration(quantity, Duration.Unit.SECONDS);

if (isInternalUrl(url) || timeout.seconds === 0) {
if (new SfdcUrl(url).isInternalUrl() || timeout.seconds === 0) {
return true;
}

Expand Down
13 changes: 11 additions & 2 deletions src/util/sfdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { findKey } from '@salesforce/kit';
import { AnyJson, asJsonMap, isJsonMap, JsonMap, Optional } from '@salesforce/ts-types';
import { SfdcUrl } from './sfdcUrl';

/**
* Converts an 18 character Salesforce ID to 15 characters.
Expand Down Expand Up @@ -42,11 +41,18 @@ export const validateApiVersion = (value: string): boolean => value == null || /
export const validateEmail = (value: string): boolean => /^[^.][^@]*@[^.]+(\.[^.\s]+)+$/.test(value);

/**
*
* @deprecated use `new SfdcUrl(url).isInternalUrl()`
* Tests whether a given url is an internal Salesforce domain
*
* @param url
*/
export const isInternalUrl = (url: string): boolean => new SfdcUrl(url).isInternalUrl();
export const isInternalUrl = (url: string): boolean => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const SfdcUrl = require('./sfdcUrl');
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return new SfdcUrl(url).isInternalUrl() as boolean;
};

/**
* Tests whether a Salesforce ID is in the correct format, a 15- or 18-character length string with only letters and numbers
Expand All @@ -64,7 +70,10 @@ export const validateSalesforceId = (value: string): boolean =>
export const validatePathDoesNotContainInvalidChars = (value: string): boolean =>
// eslint-disable-next-line no-useless-escape
!/[\["\?<>\|\]]+/.test(value);

/**
* @deprecated
* // TODO: move this to a module-scope function in sfProject
* Returns the first key within the object that has an upper case first letter.
*
* @param data The object in which to check key casing.
Expand Down
89 changes: 6 additions & 83 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1690,15 +1690,7 @@ default-require-extensions@^3.0.0:
dependencies:
strip-bom "^4.0.0"

define-properties@^1.1.3, define-properties@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1"
integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==
dependencies:
has-property-descriptors "^1.0.0"
object-keys "^1.1.1"

define-properties@^1.2.0:
define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5"
integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==
Expand Down Expand Up @@ -1798,46 +1790,7 @@ error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"

es-abstract@^1.19.0, es-abstract@^1.20.4:
version "1.21.1"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.1.tgz#e6105a099967c08377830a0c9cb589d570dd86c6"
integrity sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==
dependencies:
available-typed-arrays "^1.0.5"
call-bind "^1.0.2"
es-set-tostringtag "^2.0.1"
es-to-primitive "^1.2.1"
function-bind "^1.1.1"
function.prototype.name "^1.1.5"
get-intrinsic "^1.1.3"
get-symbol-description "^1.0.0"
globalthis "^1.0.3"
gopd "^1.0.1"
has "^1.0.3"
has-property-descriptors "^1.0.0"
has-proto "^1.0.1"
has-symbols "^1.0.3"
internal-slot "^1.0.4"
is-array-buffer "^3.0.1"
is-callable "^1.2.7"
is-negative-zero "^2.0.2"
is-regex "^1.1.4"
is-shared-array-buffer "^1.0.2"
is-string "^1.0.7"
is-typed-array "^1.1.10"
is-weakref "^1.0.2"
object-inspect "^1.12.2"
object-keys "^1.1.1"
object.assign "^4.1.4"
regexp.prototype.flags "^1.4.3"
safe-regex-test "^1.0.0"
string.prototype.trimend "^1.0.6"
string.prototype.trimstart "^1.0.6"
typed-array-length "^1.0.4"
unbox-primitive "^1.0.2"
which-typed-array "^1.1.9"

es-abstract@^1.21.2:
es-abstract@^1.19.0, es-abstract@^1.20.4, es-abstract@^1.21.2:
version "1.22.1"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.1.tgz#8b4e5fc5cefd7f1660f0f8e1a52900dfbc9d9ccc"
integrity sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==
Expand Down Expand Up @@ -2389,16 +2342,7 @@ get-func-name@^2.0.0:
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==

get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f"
integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==
dependencies:
function-bind "^1.1.1"
has "^1.0.3"
has-symbols "^1.0.3"

get-intrinsic@^1.2.1:
get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82"
integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==
Expand Down Expand Up @@ -2755,7 +2699,7 @@ inquirer@^7.0.0:
strip-ansi "^6.0.0"
through "^2.3.6"

internal-slot@^1.0.4, internal-slot@^1.0.5:
internal-slot@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986"
integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==
Expand Down Expand Up @@ -3690,7 +3634,7 @@ nyc@^15.1.0:
test-exclude "^6.0.0"
yargs "^15.0.2"

object-inspect@^1.12.2, object-inspect@^1.12.3, object-inspect@^1.9.0:
object-inspect@^1.12.3, object-inspect@^1.9.0:
version "1.12.3"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9"
integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==
Expand Down Expand Up @@ -4173,15 +4117,6 @@ regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==

regexp.prototype.flags@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac"
integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==
dependencies:
call-bind "^1.0.2"
define-properties "^1.1.3"
functions-have-names "^1.2.2"

regexp.prototype.flags@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb"
Expand Down Expand Up @@ -4359,7 +4294,7 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.4, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0:
semver@^7.3.4, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0, semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
Expand Down Expand Up @@ -5070,18 +5005,6 @@ which-typed-array@^1.1.10:
gopd "^1.0.1"
has-tostringtag "^1.0.0"

which-typed-array@^1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6"
integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==
dependencies:
available-typed-arrays "^1.0.5"
call-bind "^1.0.2"
for-each "^0.3.3"
gopd "^1.0.1"
has-tostringtag "^1.0.0"
is-typed-array "^1.1.10"

[email protected], which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
Expand Down

0 comments on commit 5636083

Please sign in to comment.