Skip to content

Commit

Permalink
fix: avoid duplicate STL listeners when multiple instances exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Sep 27, 2023
1 parent 4adb3c2 commit 23044f1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"node": ">=16.0.0"
},
"dependencies": {
"@salesforce/core": "^5.2.0",
"@salesforce/core": "^5.3.0",
"@salesforce/kit": "^3.0.9",
"@salesforce/source-deploy-retrieve": "^9.7.15",
"@salesforce/ts-types": "^2.0.6",
Expand Down
64 changes: 40 additions & 24 deletions src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,35 +660,51 @@ export class SourceTracking extends AsyncCreatable {
if (!this.ignoreConflicts) {
this.logger.debug('subscribing to predeploy/retrieve events');
// subscribe to SDR `pre` events to handle conflicts before deploy/retrieve
lifecycle.on('scopedPreDeploy', async (e: ScopedPreDeploy) => {
this.logger.debug('received scopedPreDeploy event');
if (e.orgId === this.orgId) {
throwIfConflicts(findConflictsInComponentSet(e.componentSet, await this.getConflicts()));
}
});
lifecycle.on('scopedPreRetrieve', async (e: ScopedPreRetrieve) => {
this.logger.debug('received scopedPreRetrieve event');
if (e.orgId === this.orgId) {
throwIfConflicts(findConflictsInComponentSet(e.componentSet, await this.getConflicts()));
}
});
lifecycle.on(
'scopedPreDeploy',
async (e: ScopedPreDeploy) => {
this.logger.debug('received scopedPreDeploy event');
if (e.orgId === this.orgId) {
throwIfConflicts(findConflictsInComponentSet(e.componentSet, await this.getConflicts()));
}
},
`stl#scopedPreDeploy-${this.orgId}`
);
lifecycle.on(
'scopedPreRetrieve',
async (e: ScopedPreRetrieve) => {
this.logger.debug('received scopedPreRetrieve event');
if (e.orgId === this.orgId) {
throwIfConflicts(findConflictsInComponentSet(e.componentSet, await this.getConflicts()));
}
},
`stl#scopedPreRetrieve-${this.orgId}`
);
}
// subscribe to SDR post-deploy event
this.logger.debug('subscribing to postdeploy/retrieve events');

// yes, the post hooks really have different payloads!
lifecycle.on('scopedPostDeploy', async (e: ScopedPostDeploy) => {
this.logger.debug('received scopedPostDeploy event');
if (e.orgId === this.orgId && e.deployResult.response.success) {
await this.updateTrackingFromDeploy(e.deployResult);
}
});
lifecycle.on('scopedPostRetrieve', async (e: ScopedPostRetrieve) => {
this.logger.debug('received scopedPostRetrieve event');
if (e.orgId === this.orgId && e.retrieveResult.response.success) {
await this.updateTrackingFromRetrieve(e.retrieveResult);
}
});
lifecycle.on(
'scopedPostDeploy',
async (e: ScopedPostDeploy) => {
this.logger.debug('received scopedPostDeploy event');
if (e.orgId === this.orgId && e.deployResult.response.success) {
await this.updateTrackingFromDeploy(e.deployResult);
}
},
`stl#scopedPostDeploy-${this.orgId}`
);
lifecycle.on(
'scopedPostRetrieve',
async (e: ScopedPostRetrieve) => {
this.logger.debug('received scopedPostRetrieve event');
if (e.orgId === this.orgId && e.retrieveResult.response.success) {
await this.updateTrackingFromRetrieve(e.retrieveResult);
}
},
`stl#scopedPostRetrieve-${this.orgId}`
);
}
}

Expand Down
32 changes: 7 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,10 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.7.0"

"@salesforce/core@^5.2.0", "@salesforce/core@^5.2.7", "@salesforce/core@^5.2.9":
version "5.2.10"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-5.2.10.tgz#7f4824ddcef108b6ccec24434260c620de39012e"
integrity sha512-Xj1QRajmHWgl0ahivjKFGKJlGXwe9yFOZ3PwF91qEupGbO74XrCJ8OUM7EVlk53LKy9LlPZQFuy2ATX9MyEDKA==
"@salesforce/core@^5.2.0", "@salesforce/core@^5.2.7", "@salesforce/core@^5.2.9", "@salesforce/core@^5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-5.3.0.tgz#2cf9e2ed7c32c59ae04af185d6906d681adffc4e"
integrity sha512-8Jlvv9CfkKc53o2uFsWDHqIKjn1nhlzHvxAN96cmph2jq2480kb24U8ouGm6FRGeBiBodYUN5cFJKnOpAXMrig==
dependencies:
"@salesforce/kit" "^3.0.11"
"@salesforce/schemas" "^1.6.0"
Expand Down Expand Up @@ -904,12 +904,7 @@
dependencies:
"@types/node" "*"

"@types/semver@^7.3.12":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==

"@types/semver@^7.5.2":
"@types/semver@^7.3.12", "@types/semver@^7.5.2":
version "7.5.2"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.2.tgz#31f6eec1ed7ec23f4f05608d3a2d381df041f564"
integrity sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==
Expand Down Expand Up @@ -4459,15 +4454,7 @@ pify@^4.0.1:
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==

pino-abstract-transport@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz#cc0d6955fffcadb91b7b49ef220a6cc111d48bb3"
integrity sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA==
dependencies:
readable-stream "^4.0.0"
split2 "^4.0.0"

pino-abstract-transport@v1.1.0:
pino-abstract-transport@^1.0.0, pino-abstract-transport@v1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.1.0.tgz#083d98f966262164504afb989bccd05f665937a8"
integrity sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==
Expand Down Expand Up @@ -5431,12 +5418,7 @@ ts-prune@^0.10.3:
"true-myth" "^4.1.0"
ts-morph "^13.0.1"

ts-retry-promise@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/ts-retry-promise/-/ts-retry-promise-0.7.0.tgz#08f2dcbbf5d2981495841cb63389a268324e8147"
integrity sha512-x6yWZXC4BfXy4UyMweOFvbS1yJ/Y5biSz/mEPiILtJZLrqD3ZxIpzVOGGgifHHdaSe3WxzFRtsRbychI6zofOg==

ts-retry-promise@^0.7.1:
ts-retry-promise@^0.7.0, ts-retry-promise@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ts-retry-promise/-/ts-retry-promise-0.7.1.tgz#176d6eee6415f07b6c7c286d3657355e284a6906"
integrity sha512-NhHOCZ2AQORvH42hOPO5UZxShlcuiRtm7P2jIq2L2RY3PBxw2mLnUsEdHrIslVBFya1v5aZmrR55lWkzo13LrQ==
Expand Down

0 comments on commit 23044f1

Please sign in to comment.