Skip to content

Conversation

@mshanemc
Copy link
Contributor

What does this PR do?

by default, getFileResponses makes the file paths relative to cwd.
in extensions, cwd is always / by default (current extensions manipulate it via chdir but that's not going to happen on the web)

if the CompSet has a projectDirectory set, and it's different from cwd, make it relative to that.

//note: when we do the major version of SDR, I'd LOVE to have the DeployResult be an immutable object including fileResponses, calculated once, instead of a class with a method you call to calculate them (and then see if anyone's using the other public properties or if some are only there to be able to calculate the fileResponses.

What issues does this PR fix or reference?

@W-20175875@

@mshanemc mshanemc marked this pull request as ready for review November 20, 2025 13:22
@mshanemc mshanemc requested a review from a team as a code owner November 20, 2025 13:22
import { SfError } from '@salesforce/core/sfError';
import { ensureArray } from '@salesforce/kit';
import { ComponentLike, SourceComponent } from '../resolve';
import { SourceComponentWithContent, SourceComponent } from '../resolve/sourceComponent';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SourceComponentWithContent passed the rule of 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rule of 3 in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the same code is in 3 places, make it shared/reusable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now there's SouceComponentWithContent instead of several places making SourceComponent & {content: string}

(filePath: string): string => {
// Normalize paths to ensure relative() works correctly on Windows
const normalizedContent = component.content.split(sep).join(posix.sep);
const normalizedFilePath = filePath.split(sep).join(posix.sep);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took me a while of playing with it, but since both of these are relative, and then posix.relative is between them, then I think it should be ok even without cwd?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds right to me?

*/
import { SourceComponent, SourceComponentWithContent } from '../resolve/sourceComponent';

export const isWebAppBundle = (component: SourceComponent): component is SourceComponentWithContent =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was repeated in a few places. made it a TS guard to help stuff downstream of the guard not have to barbarically assert content!

Copy link
Contributor

@jfeingold35 jfeingold35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that we can add test coverage for?

import { SfError } from '@salesforce/core/sfError';
import { ensureArray } from '@salesforce/kit';
import { ComponentLike, SourceComponent } from '../resolve';
import { SourceComponentWithContent, SourceComponent } from '../resolve/sourceComponent';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rule of 3 in this context?

(filePath: string): string => {
// Normalize paths to ensure relative() works correctly on Windows
const normalizedContent = component.content.split(sep).join(posix.sep);
const normalizedFilePath = filePath.split(sep).join(posix.sep);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds right to me?

@jfeingold35 jfeingold35 merged commit f350cd6 into main Nov 20, 2025
88 of 89 checks passed
@jfeingold35 jfeingold35 deleted the sm/web-compatibility branch November 20, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants