Skip to content
Open
Changes from all 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
22 changes: 22 additions & 0 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ComponentStatus,
DeployResult,
DestructiveChangesType,
expandD360ComponentSet,
FileResponseSuccess,
MetadataApiDeploy,
MetadataApiDeployOptions,
Expand Down Expand Up @@ -119,6 +120,22 @@ export async function buildComponentSet(opts: Partial<DeployOptions>, stl?: Sour
});
}

/** True when the deploy includes at least one Data Cloud dataspace-scoped component. */
const hasD360Components = (requested: ComponentSet): boolean =>
[...requested.getSourceComponents()].some((c) => c.type.strategies?.adapter === 'd360');

/**
* A dataspace-scoped component's sidecar lists the peers it has to be deployed alongside, under
* `retrieveWith`. So when someone deploys one of these, we also pull in those peers (and their peers,
* and so on) — but nothing else from the project. To find them we resolve the whole project once,
* then hand back the requested set plus that closure.
*/
async function expandD360Closure(requested: ComponentSet, registry?: RegistryAccess): Promise<ComponentSet> {
// Resolve the whole project so we can look up the retrieveWith peers by their sidecar componentName.
const full = await ComponentSetBuilder.build({ sourcepath: await getPackageDirs() });
return expandD360ComponentSet(full, requested, registry);
}

export async function executeDeploy(
opts: Partial<DeployOptions>,
project?: SfProject,
Expand Down Expand Up @@ -166,6 +183,11 @@ export async function executeDeploy(
registry = stl.registry;

componentSet = await buildComponentSet(opts, stl);
// Dataspace-scoped components need their retrieveWith peers in the same deploy, so pull those in.
// Every other deploy leaves the component set untouched.
if (hasD360Components(componentSet)) {
componentSet = await expandD360Closure(componentSet, registry);
}
if (componentSet.size === 0) {
if (opts['source-dir'] ?? opts.manifest ?? opts.metadata ?? throwOnEmpty) {
// the user specified something to deploy, but there isn't anything
Expand Down