Skip to content

Commit

Permalink
fix: use new SDR registry property supportsPartialDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Nov 21, 2022
1 parent ec7dbd5 commit aaa6c38
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@salesforce/core": "^3.31.19",
"@salesforce/kit": "^1.8.0",
"@salesforce/source-deploy-retrieve": "^7.5.9",
"@salesforce/source-deploy-retrieve": "^7.5.12",
"graceful-fs": "^4.2.10",
"isomorphic-git": "1.17.0",
"ts-retry-promise": "^0.7.0"
Expand Down
11 changes: 1 addition & 10 deletions src/shared/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ export const getKeyFromObject = (element: RemoteChangeElement | ChangeResult): s
throw new Error(`unable to complete key from ${JSON.stringify(element)}`);
};

// Return whether a component is part of a bundle. Note that this applies to SDR bundle
// types, but it also applies to some special types that are not technically classified
// in SDR as bundles, such as DigitalExperienceBundle, ExperienceBundle, and StaticResources.
// These types share characteristics of bundle types.
export const isBundle = (cmp: SourceComponent): boolean => {
const cmpTypeAdapter = cmp.type.strategies?.adapter;
const cmpTypeName = cmp.type.name;
const bundleLikeTypes = ['DigitalExperience', 'DigitalExperienceBundle', 'ExperienceBundle', 'StaticResource'];
return cmpTypeAdapter === 'bundle' || bundleLikeTypes.includes(cmpTypeName);
};
export const supportsPartialDelete = (cmp: SourceComponent): boolean => !!cmp.type.supportsPartialDelete;

export const isLwcLocalOnlyTest = (filePath: string): boolean =>
filePath.includes('__utam__') || filePath.includes('__tests__');
Expand Down
8 changes: 4 additions & 4 deletions src/shared/localComponentSetArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
DestructiveChangesType,
} from '@salesforce/source-deploy-retrieve';
import { sourceComponentGuard } from './guards';
import { isBundle, pathIsInFolder } from './functions';
import { supportsPartialDelete, pathIsInFolder } from './functions';

interface GroupedFileInput {
packageDirs: NamedPackageDir[];
Expand Down Expand Up @@ -76,9 +76,9 @@ export const getComponentSets = (groupings: GroupedFile[], sourceApiVersion?: st
.flatMap((filename) => resolverForDeletes.getComponentsFromPath(filename))
.filter(sourceComponentGuard)
.map((component) => {
// if the component is part of a bundle AND there are files from the bundle that are not deleted,
// set the bundle for deploy, not for delete.
if (isBundle(component) && component.content && fs.existsSync(component.content)) {
// if the component supports partial delete AND there are files that are not deleted,
// set the component for deploy, not for delete.
if (supportsPartialDelete(component) && component.content && fs.existsSync(component.content)) {
// all bundle types have a directory name
try {
resolverForNonDeletes
Expand Down
4 changes: 2 additions & 2 deletions src/sourceTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
RemoteChangeElement,
} from './shared/types';
import { sourceComponentGuard } from './shared/guards';
import { isBundle, pathIsInFolder, ensureRelative } from './shared/functions';
import { supportsPartialDelete, pathIsInFolder, ensureRelative } from './shared/functions';
import { registrySupportsType } from './shared/metadataKeys';
import { hasSfdxTrackingFiles } from './compatibility';
import { populateFilePaths } from './shared/populateFilePaths';
Expand Down Expand Up @@ -403,7 +403,7 @@ export class SourceTracking extends AsyncCreatable {
const bundlesWithDeletedFiles = (
await this.getChanges({ origin: 'local', state: 'delete', format: 'SourceComponent' })
)
.filter(isBundle)
.filter(supportsPartialDelete)
.filter((cmp) => deployedFilesAsVirtualComponentSet.has({ type: cmp.type, fullName: cmp.fullName }))
.map((cmp) => cmp.content)
.filter(isString);
Expand Down
35 changes: 29 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.7.0"

"@salesforce/core@^3.30.9", "@salesforce/core@^3.31.17", "@salesforce/core@^3.31.19":
"@salesforce/core@^3.30.9", "@salesforce/core@^3.31.19":
version "3.31.19"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.31.19.tgz#29366aee1e9e271d3bef6d0a5e60204f3885daf7"
integrity sha512-Qx4F7n+1eENICD9yvTrSI5+HVbjZ/B3vzNjdjZ4aNHO5MvEgg93vs1KeGujfGU4lzaEj5Wuy7delp5wJC0a1aA==
Expand All @@ -696,6 +696,29 @@
jsonwebtoken "8.5.1"
ts-retry-promise "^0.7.0"

"@salesforce/core@^3.32.1":
version "3.32.1"
resolved "https://registry.npmjs.org/@salesforce/core/-/core-3.32.1.tgz#1a338a1985c58c1be819f99c6b33b24b32817cbe"
integrity sha512-hVcweKGy1CS3t0duS+0jxGVou5ZoQMXRZPQmcz1FyW31Oef5U07rhs3wTrwJqhCPHL817R/gm5V9wSRNcYdDtA==
dependencies:
"@salesforce/bunyan" "^2.0.0"
"@salesforce/kit" "^1.8.0"
"@salesforce/schemas" "^1.1.0"
"@salesforce/ts-types" "^1.5.21"
"@types/graceful-fs" "^4.1.5"
"@types/semver" "^7.3.9"
ajv "^8.11.0"
archiver "^5.3.0"
change-case "^4.1.2"
debug "^3.2.7"
faye "^1.4.0"
form-data "^4.0.0"
graceful-fs "^4.2.9"
js2xmlparser "^4.0.1"
jsforce "^2.0.0-beta.19"
jsonwebtoken "8.5.1"
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 @@ -759,12 +782,12 @@
resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.1.3.tgz#fce83f55c7557d47b9c814d5d02978ad734300b3"
integrity sha512-XWohlOT2oQDqAJH00OXS3f2MGjkwZ6pr4emnnkHSQbg7UdGW0rvGpEnRKqBbDUfZ4K5YKSo9Gj216ZtaP3JLXg==

"@salesforce/source-deploy-retrieve@^7.5.9":
version "7.5.9"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-7.5.9.tgz#8919f186d434bee0a406db59bd0aae0a597c733f"
integrity sha512-NFB2ogQvwdpzjf3+c0MewXDgmY4B6uA1DRsf/fwIriNYsN3f96WI/BG5cf72HeHrhndaZ8/eBZp7yEPNLJTjjA==
"@salesforce/source-deploy-retrieve@^7.5.12":
version "7.5.12"
resolved "https://registry.npmjs.org/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-7.5.12.tgz#6926f06b399d620268245316305dd4d772c5099f"
integrity sha512-fj8b33UtfH3cW2pEYPIs6UOFADy7dK2LwjAgCm2lzPDWwlAuBIhYDrnuuZaH8/fMoz4p7k81QXWXbLo3sMDntw==
dependencies:
"@salesforce/core" "^3.31.17"
"@salesforce/core" "^3.32.1"
"@salesforce/kit" "^1.8.0"
"@salesforce/ts-types" "^1.7.1"
archiver "^5.3.1"
Expand Down

0 comments on commit aaa6c38

Please sign in to comment.