-
Notifications
You must be signed in to change notification settings - Fork 143
feat: web compatibility W-20175875 #1650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| import { SfError } from '@salesforce/core/sfError'; | ||
| import { ensureArray } from '@salesforce/kit'; | ||
| import { ComponentLike, SourceComponent } from '../resolve'; | ||
| import { SourceComponentWithContent, SourceComponent } from '../resolve/sourceComponent'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 => |
There was a problem hiding this comment.
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!
jfeingold35
left a comment
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
What does this PR do?
by default, getFileResponses makes the file paths relative to cwd.
in extensions,
cwdis 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@