Skip to content

Commit

Permalink
fix: use SF prefixed env vars, add UTs, SDR 9, core 4
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed May 31, 2023
1 parent ed326cb commit 3e4aba6
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 31 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"/oclif.manifest.json"
],
"dependencies": {
"@salesforce/core": "^3.36.1",
"@salesforce/core": "^4.0.1",
"@salesforce/kit": "^1.9.2",
"@salesforce/source-deploy-retrieve": "^8.5.1",
"@salesforce/source-deploy-retrieve": "^9.1.0",
"fast-xml-parser": "^4.2.2",
"graceful-fs": "^4.2.11",
"isomorphic-git": "1.23.0",
Expand Down Expand Up @@ -160,4 +160,4 @@
"output": []
}
}
}
}
9 changes: 6 additions & 3 deletions src/shared/localShadowRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ export class ShadowRepo {
private packageDirs!: NamedPackageDir[];
private status!: StatusRow[];
private logger!: Logger;
private isWindows: boolean;
private readonly isWindows: boolean;

/** do not try to add more than this many files at a time through isogit. You'll hit EMFILE: too many open files even with graceful-fs */
private maxFileAdd: number;
private readonly maxFileAdd: number;

private constructor(options: ShadowRepoOptions) {
this.gitDir = getGitDir(options.orgId, options.projectPath);
this.projectPath = options.projectPath;
this.packageDirs = options.packageDirs;
this.isWindows = os.type() === 'Windows_NT';

this.maxFileAdd = env.getNumber('SFDX_SOURCE_TRACKING_BATCH_SIZE', this.isWindows ? 8000 : 15000);
this.maxFileAdd = env.getNumber(
'SF_SOURCE_TRACKING_BATCH_SIZE',
env.getNumber('SFDX_SOURCE_TRACKING_BATCH_SIZE', this.isWindows ? 8000 : 15000)
);
}

// think of singleton behavior but unique to the projectPath
Expand Down
2 changes: 1 addition & 1 deletion src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class SourceTracking extends AsyncCreatable {

/**
* Mark remote source tracking files so say that we have received the latest version from the server
* Optionall skip polling for the SourceMembers to exist on the server and be updated in local files
* Optional skip polling for the SourceMembers to exist on the server and be updated in local files
*/
public async updateRemoteTracking(fileResponses: RemoteSyncInput[], skipPolling = false): Promise<void> {
// false to explicitly NOT query until we do the polling
Expand Down
71 changes: 71 additions & 0 deletions test/unit/localShadowRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,75 @@ describe('localShadowRepo', () => {
if (projectDir) await fs.promises.rm(projectDir, { recursive: true });
}
});
it('respects SFDX_SOURCE_TRACKING_BATCH_SIZE env var', async () => {
expect(process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE = '1';
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));

const shadowRepo: ShadowRepo = await ShadowRepo.getInstance({
orgId: '00D456789012345',
projectPath: projectDir,
packageDirs: [
{
name: 'dummy',
fullPath: 'dummy',
path: path.join(projectDir, 'force-app'),
},
],
});
// private property maxFileAdd
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect(shadowRepo.maxFileAdd).to.equal(1);
delete process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE;
expect(process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
});

it('respects SF_SOURCE_TRACKING_BATCH_SIZE env var', async () => {
expect(process.env.SF_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
process.env.SF_SOURCE_TRACKING_BATCH_SIZE = '1';
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));

const shadowRepo: ShadowRepo = await ShadowRepo.getInstance({
orgId: '00D456789012345',
projectPath: projectDir,
packageDirs: [
{
name: 'dummy',
fullPath: 'dummy',
path: path.join(projectDir, 'force-app'),
},
],
});
// private property maxFileAdd
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect(shadowRepo.maxFileAdd).to.equal(1);
delete process.env.SF_SOURCE_TRACKING_BATCH_SIZE;
expect(process.env.SF_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
});

it('respects undefined SF_SOURCE_TRACKING_BATCH_SIZE env var and uses default', async () => {
expect(process.env.SF_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
expect(process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));

const shadowRepo: ShadowRepo = await ShadowRepo.getInstance({
orgId: '00D456789012345',
projectPath: projectDir,
packageDirs: [
{
name: 'dummy',
fullPath: 'dummy',
path: path.join(projectDir, 'force-app'),
},
],
});
// private property maxFileAdd
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect(shadowRepo.maxFileAdd).to.equal(os.type() === 'Windows_NT' ? 8000 : 15000);
expect(process.env.SF_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
expect(process.env.SFDX_SOURCE_TRACKING_BATCH_SIZE).to.be.undefined;
});
});
106 changes: 82 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,27 @@
jsonwebtoken "9.0.0"
ts-retry-promise "^0.7.0"

"@salesforce/core@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-4.0.1.tgz#d843c86cfd59f74e33e70d9558e0fe3ee9b49a53"
integrity sha512-BjHM3C3QfjW0wSrt0q2+5JOwa/9edg/18TT2C3iykmPxeDXAum/2W/S+7ctyefEJ0/VYlh/DvzLaEc74MadKnA==
dependencies:
"@salesforce/bunyan" "^2.0.0"
"@salesforce/kit" "^3.0.0"
"@salesforce/schemas" "^1.5.1"
"@salesforce/ts-types" "^2.0.1"
"@types/semver" "^7.3.13"
ajv "^8.12.0"
archiver "^5.3.0"
change-case "^4.1.2"
debug "^3.2.7"
faye "^1.4.0"
form-data "^4.0.0"
js2xmlparser "^4.0.1"
jsforce "^2.0.0-beta.23"
jsonwebtoken "9.0.0"
ts-retry-promise "^0.7.0"

"@salesforce/dev-config@^3.0.0", "@salesforce/dev-config@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@salesforce/dev-config/-/dev-config-3.1.0.tgz#8eb5b35860ff60d1c1dc3fd9329b01a28475d5b9"
Expand Down Expand Up @@ -965,6 +986,14 @@
shx "^0.3.3"
tslib "^2.5.0"

"@salesforce/kit@^3.0.0", "@salesforce/kit@^3.0.1":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@salesforce/kit/-/kit-3.0.2.tgz#6474c3e9905290bbcfb3455388b140eee3ff84db"
integrity sha512-/TbqjmxThz3+ZeLrYZFEcvn7kbK7DW0aHzotazyKsoGbqsHiiXIMNS1Cc5rfJRKQV7bKp84vMF/WCyBZJFHZKA==
dependencies:
"@salesforce/ts-types" "^2.0.1"
tslib "^2.5.2"

"@salesforce/prettier-config@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@salesforce/prettier-config/-/prettier-config-0.0.2.tgz#ded39bf7cb75238edc9db6dd093649111350f8bc"
Expand All @@ -975,25 +1004,25 @@
resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.5.1.tgz#2d1bfdcf593caaa04cd4b3e6fe621097ff7f28fe"
integrity sha512-MRqU+tn8w5IFvZ0Lm9YKLgxYxr2MQMI+fXXsTrwfUnijsps+ybF9IOTu6MOMxxl2vCUkO8XDjA435wXlWSLI6g==

"@salesforce/source-deploy-retrieve@^8.5.1":
version "8.5.1"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-8.5.1.tgz#f66f590348857aa51e11fdb69dbd9fcf1d2fba93"
integrity sha512-bdbyLlpILlGiNzsqrZjOEu3rtp3pqQyPzixL2CA9UebKGytG6zT3J6+/0Br1jAVefbl62KW6dgwurAVL7bp6+w==
"@salesforce/source-deploy-retrieve@^9.1.0":
version "9.1.0"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-9.1.0.tgz#61cc4dbde890a8160409e748c4ac59e6f698930d"
integrity sha512-ZD5dIZPwPGqP+N/HvQLieV4QhzXZw5dvvhA6Vpgdbt7SpFjjncYnvaOLh6+GdnIKMcA/jWpEXym51vwj6jZb1A==
dependencies:
"@salesforce/core" "^3.36.1"
"@salesforce/kit" "^1.9.2"
"@salesforce/ts-types" "^1.7.2"
archiver "^5.3.1"
"@salesforce/core" "^4.0.1"
"@salesforce/kit" "^3.0.1"
"@salesforce/ts-types" "^2.0.2"
fast-levenshtein "^3.0.0"
fast-xml-parser "^4.2.2"
got "^11.8.6"
graceful-fs "^4.2.11"
ignore "^5.2.4"
jszip "^3.10.1"
mime "2.6.0"
minimatch "^5.1.6"
proxy-agent "^5.0.0"
proxy-from-env "^1.1.0"
unzipper "0.10.11"
unzipper "0.10.14"

"@salesforce/ts-sinon@^1.4.6":
version "1.4.6"
Expand All @@ -1011,6 +1040,13 @@
dependencies:
tslib "^2.5.0"

"@salesforce/ts-types@^2.0.1", "@salesforce/ts-types@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-2.0.2.tgz#44c2ab3a765b57a9a285f2be31a661ac5b373ac3"
integrity sha512-FxQnTtdn9mcnGpc6qxQbpP+0CnDY1OcMNM+QL+TgC5uSyxnzo6vBrK7OenrK9jdgfvJZAKH1PjeAj2QahbpBwQ==
dependencies:
tslib "^2.5.2"

"@sindresorhus/is@^4.0.0":
version "4.6.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f"
Expand Down Expand Up @@ -1588,7 +1624,7 @@ archiver-utils@^2.1.0:
normalize-path "^3.0.0"
readable-stream "^2.0.0"

archiver@^5.2.0, archiver@^5.3.0, archiver@^5.3.1:
archiver@^5.2.0, archiver@^5.3.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/archiver/-/archiver-5.3.1.tgz#21e92811d6f09ecfce649fbefefe8c79e57cbbb6"
integrity sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==
Expand Down Expand Up @@ -4036,6 +4072,11 @@ ignore@^5.1.4, ignore@^5.2.0, ignore@^5.2.4:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==

immediate@~3.0.5:
version "3.0.6"
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==

import-fresh@^3.0.0, import-fresh@^3.2.1:
version "3.3.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
Expand Down Expand Up @@ -4559,10 +4600,10 @@ jsesc@^2.5.1:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==

jsforce@^2.0.0-beta.21:
version "2.0.0-beta.21"
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.21.tgz#04c94d762d2536bf1af3062d5cca206656f5b12b"
integrity sha512-74GUF/96vYBNZo3SUccXtt4CmfvZ0iqTSc0Z3OB940Ec7oU6coOAGhlCZ+XprXaHOMMhXMXrZQ1PCd16yjIA7A==
jsforce@^2.0.0-beta.21, jsforce@^2.0.0-beta.23:
version "2.0.0-beta.23"
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.23.tgz#5eeb1a2635498ee77f0726ababe089cc12113551"
integrity sha512-lfeLHbCJ40ela1JPu4VqgK1GtIzR0NQOMZ/Rxesv9Ty3PyxK18o01AQ4E+JqGAWDDQhwyUp2A/9V+uOqU3w7Rw==
dependencies:
"@babel/runtime" "^7.12.5"
"@babel/runtime-corejs3" "^7.12.5"
Expand Down Expand Up @@ -4668,6 +4709,16 @@ jsonwebtoken@9.0.0:
ms "^2.1.1"
semver "^7.3.8"

jszip@^3.10.1:
version "3.10.1"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2"
integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==
dependencies:
lie "~3.3.0"
pako "~1.0.2"
readable-stream "~2.3.6"
setimmediate "^1.0.5"

just-diff-apply@^5.2.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/just-diff-apply/-/just-diff-apply-5.5.0.tgz#771c2ca9fa69f3d2b54e7c3f5c1dfcbcc47f9f0f"
Expand Down Expand Up @@ -4735,6 +4786,13 @@ levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lie@~3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==
dependencies:
immediate "~3.0.5"

lines-and-columns@^1.1.6:
version "1.2.4"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
Expand Down Expand Up @@ -5890,7 +5948,7 @@ pad-component@0.0.1:
resolved "https://registry.yarnpkg.com/pad-component/-/pad-component-0.0.1.tgz#ad1f22ce1bf0fdc0d6ddd908af17f351a404b8ac"
integrity sha512-8EKVBxCRSvLnsX1p2LlSFSH3c2/wuhY9/BXXWu8boL78FbVKqn2L5SpURt1x5iw6Gq8PTqJ7MdPoe5nCtX3I+g==

pako@^1.0.10:
pako@^1.0.10, pako@~1.0.2:
version "1.0.11"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
Expand Down Expand Up @@ -6583,7 +6641,7 @@ set-blocking@^2.0.0:
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==

setimmediate@~1.0.4:
setimmediate@^1.0.5, setimmediate@~1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
Expand Down Expand Up @@ -7244,10 +7302,10 @@ tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.1, tslib@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
tslib@^2, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.1, tslib@^2.5.0, tslib@^2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.2.tgz#1b6f07185c881557b0ffa84b111a0106989e8338"
integrity sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA==

tsutils@^3.21.0:
version "3.21.0"
Expand Down Expand Up @@ -7416,10 +7474,10 @@ untildify@^4.0.0:
resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b"
integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==

unzipper@0.10.11:
version "0.10.11"
resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e"
integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw==
unzipper@0.10.14:
version "0.10.14"
resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.14.tgz#d2b33c977714da0fbc0f82774ad35470a7c962b1"
integrity sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==
dependencies:
big-integer "^1.6.17"
binary "~0.3.0"
Expand Down

0 comments on commit 3e4aba6

Please sign in to comment.