Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@salesforce/core": "^8.0.3",
"@salesforce/core": "^8.0.5",
"@salesforce/kit": "^3.1.6",
"@salesforce/ts-types": "^2.0.10",
"fast-levenshtein": "^3.0.0",
Expand All @@ -39,7 +39,7 @@
"proxy-agent": "^6.4.0"
},
"devDependencies": {
"@jsforce/jsforce-node": "^3.2.0",
"@jsforce/jsforce-node": "^3.2.1",
"@salesforce/cli-plugins-testkit": "^5.3.16",
"@salesforce/dev-scripts": "^10.2.2",
"@types/deep-equal-in-any-order": "^1.0.1",
Expand Down
6 changes: 6 additions & 0 deletions src/registry/registryAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ export class RegistryAccess {
}
}
}

/** decomposed and default types are `false`, everything else is true */
export const typeAllowsMetadataWithContent = (type: MetadataType): boolean =>
type.strategies?.adapter !== undefined && // another way of saying default
type.strategies.adapter !== 'decomposed' &&
type.strategies.adapter !== 'default';
12 changes: 2 additions & 10 deletions src/resolve/adapters/baseSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { NodeFSTreeContainer, TreeContainer } from '../treeContainers';
import { SourceComponent } from '../sourceComponent';
import { SourcePath } from '../../common/types';
import { MetadataType } from '../../registry/types';
import { RegistryAccess } from '../../registry/registryAccess';
import { RegistryAccess, typeAllowsMetadataWithContent } from '../../registry/registryAccess';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/source-deploy-retrieve', 'sdr');
Expand All @@ -30,7 +30,6 @@ export abstract class BaseSourceAdapter implements SourceAdapter {
* folder, including its root metadata xml file.
*/
protected ownFolder = false;
protected metadataWithContent = true;

public constructor(
type: MetadataType,
Expand Down Expand Up @@ -77,13 +76,6 @@ export abstract class BaseSourceAdapter implements SourceAdapter {
return this.populate(path, component, isResolvingSource);
}

/**
* Control whether metadata and content metadata files are allowed for an adapter.
*/
public allowMetadataWithContent(): boolean {
return this.metadataWithContent;
}

/**
* If the path given to `getComponent` is the root metadata xml file for a component,
* parse the name and return it. This is an optimization to not make a child adapter do
Expand Down Expand Up @@ -114,7 +106,7 @@ export abstract class BaseSourceAdapter implements SourceAdapter {
return folderMetadataXml;
}

if (!this.allowMetadataWithContent()) {
if (!typeAllowsMetadataWithContent(this.type)) {
return parseAsContentMetadataXml(this.type)(path);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/resolve/adapters/decomposedSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const messages = Messages.loadMessages('@salesforce/source-deploy-retrieve', 'sd
*/
export class DecomposedSourceAdapter extends MixedContentSourceAdapter {
protected ownFolder = true;
protected metadataWithContent = false;

public getComponent(path: SourcePath, isResolvingSource = true): SourceComponent | undefined {
let rootMetadata = super.parseAsRootMetadataXml(path);
Expand Down
2 changes: 0 additions & 2 deletions src/resolve/adapters/defaultSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { BaseSourceAdapter } from './baseSourceAdapter';
*```
*/
export class DefaultSourceAdapter extends BaseSourceAdapter {
protected metadataWithContent = false;

/* istanbul ignore next */
// retained to preserve API
// eslint-disable-next-line class-methods-use-this
Expand Down
21 changes: 12 additions & 9 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { basename, dirname, sep } from 'node:path';
import { Lifecycle, Messages, SfError, Logger } from '@salesforce/core';
import { extName, fnJoin, parentName, parseMetadataXml } from '../utils/path';
import { RegistryAccess } from '../registry/registryAccess';
import { RegistryAccess, typeAllowsMetadataWithContent } from '../registry/registryAccess';
import { MetadataType } from '../registry/types';
import { ComponentSet } from '../collections/componentSet';
import { META_XML_SUFFIX } from '../common/constants';
Expand Down Expand Up @@ -125,16 +125,19 @@ export class MetadataResolver {
}
const type = resolveType(this.registry)(this.tree)(fsPath);
if (type) {
const adapter = new SourceAdapterFactory(this.registry, this.tree).getAdapter(type, this.forceIgnore);
// short circuit the component resolution unless this is a resolve for a
// source path or allowed content-only path, otherwise the adapter
// knows how to handle it
const shouldResolve =
isResolvingSource ||
parseAsRootMetadataXml(fsPath) ||
!parseAsContentMetadataXml(this.registry)(fsPath) ||
!adapter.allowMetadataWithContent();
return shouldResolve ? adapter.getComponent(fsPath, isResolvingSource) : undefined;
if (
!isResolvingSource &&
!parseAsRootMetadataXml(fsPath) &&
parseAsContentMetadataXml(this.registry)(fsPath) &&
typeAllowsMetadataWithContent(type)
) {
return;
}
const adapter = new SourceAdapterFactory(this.registry, this.tree).getAdapter(type, this.forceIgnore);
return adapter.getComponent(fsPath, isResolvingSource);
}

if (isProbablyPackageManifest(this.tree)(fsPath)) return undefined;
Expand Down Expand Up @@ -351,7 +354,7 @@ const resolveType =
/**
* Any file with a registered suffix is potentially a content metadata file.
*
* @param registry a metadata registry to resolve types agsinst
* @param registry a metadata registry to resolve types against
*/
const parseAsContentMetadataXml =
(registry: RegistryAccess) =>
Expand Down
5 changes: 0 additions & 5 deletions src/resolve/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,4 @@ export type SourceAdapter = {
* @param isResolvingSource Whether the path to resolve is a single file
*/
getComponent(fsPath: SourcePath, isResolvingSource?: boolean): SourceComponent | undefined;

/**
* Whether the adapter allows content-only metadata definitions.
*/
allowMetadataWithContent(): boolean;
};
15 changes: 1 addition & 14 deletions test/resolve/adapters/defaultSourceAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { META_XML_SUFFIX } from '../../../src/common';

describe('DefaultSourceAdapter', () => {
it('should return a SourceComponent when given a metadata xml file', () => {
const type = registry.types.apexclass;
const type = registry.types.eventdelivery;
const path = join('path', 'to', type.directoryName, `My_Test.${type.suffix}${META_XML_SUFFIX}`);
const adapter = new DefaultSourceAdapter(type);
expect(adapter.getComponent(path)).to.deep.equal(
Expand All @@ -23,17 +23,4 @@ describe('DefaultSourceAdapter', () => {
})
);
});

it('should return a SourceComponent when given a content-only metadata file', () => {
const type = registry.types.apexclass;
const path = join('path', 'to', type.directoryName, `My_Test.${type.suffix}`);
const adapter = new DefaultSourceAdapter(type);
expect(adapter.getComponent(path)).to.deep.equal(
new SourceComponent({
name: 'My_Test',
type,
xml: path,
})
);
});
});
1 change: 0 additions & 1 deletion test/resolve/registryTestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export class RegistryTestUtil {
}
getAdapterStub.withArgs(entry.type).returns({
getComponent: (path: SourcePath) => componentMap[path],
allowMetadataWithContent: () => entry.allowContent ?? false,
});
}
}
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@
"@jridgewell/resolve-uri" "3.1.0"
"@jridgewell/sourcemap-codec" "1.4.14"

"@jsforce/jsforce-node@^3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.2.0.tgz#4b104613fc9bb74e0e38d2c00936ea2b228ba73a"
integrity sha512-3GjWNgWs0HFajVhIhwvBPb0B45o500wTBNEBYxy8XjeeRra+qw8A9xUrfVU7TAGev8kXuKhjJwaTiSzThpEnew==
"@jsforce/jsforce-node@^3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.2.1.tgz#00fab05919e0cbe91ae4d873377e56cfbc087b98"
integrity sha512-hjmZQbYVikm6ATmaErOp5NaKR2VofNZsrcGGHrdbGA+bAgpfg/+MA/HzRTb8BvYyPDq3RRc5A8Yk8gx9Vtcrxg==
dependencies:
"@sindresorhus/is" "^4"
"@types/node" "^18.15.3"
Expand Down Expand Up @@ -564,12 +564,12 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.8.1"

"@salesforce/core@^8.0.3":
version "8.0.3"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.0.3.tgz#8b25ce46100baef0a8e731b42d373edf508ab144"
integrity sha512-HirswUFGQIF5Ipaa+5l3kulBOf3L25Z3fzf5QqEI4vOxgBKN2bEdKHCA/PROufi3/ejFstiXcn9/jfgyjDdBqA==
"@salesforce/core@^8.0.3", "@salesforce/core@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.0.5.tgz#f3d4af7052ff39bf06ec89af3734339b3fabe879"
integrity sha512-+p1TYvKhXWlzah7qp+vnv5W63EZm6nn7zLRvivFsL6pza0B4siHWfx11ceJ4p7W8+kh/xeuygtkddwYoLS3KkA==
dependencies:
"@jsforce/jsforce-node" "^3.2.0"
"@jsforce/jsforce-node" "^3.2.1"
"@salesforce/kit" "^3.1.6"
"@salesforce/schemas" "^1.9.0"
"@salesforce/ts-types" "^2.0.10"
Expand Down