-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(KNO-4367): Add pull email layout command #233
feat(KNO-4367): Add pull email layout command #233
Conversation
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.
Left a handful of comments/questions!
try { | ||
if (indexDirCtx.exists) { | ||
await fs.copy(indexDirCtx.abspath, backupDirPath); | ||
await fs.emptyDir(indexDirCtx.abspath); |
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 we always blow out everything in the index directory, then we won't be able to preserve the extracted file paths used in the existing email layout dirs. Could we take the approach similar to workflows where we selectively remove any email layouts that aren't found in emailLayouts
?
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.
Thanks for turning this around @Francobor2001! Overall this looks good, I left a handful of small comments, but this looks almost ready to go.
}; | ||
|
||
/* | ||
* Validate the extracted file path based on its format and uniqueness (but not |
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.
Right now I don't see we are doing a uniqueness check here, and I think we should replicate that here as well?
And in that case, we might be able to abstract out the validateExtractedFilePath
function also as a shared helper? Instead of EmailLayoutDirContext
or WorkflowDirContext
, it could take a sourceFileAbspath
string?
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.
Great idea, here's the abstraction: ce50327
// If not marked with the @suffix, there's nothing to do. | ||
if (!FILEPATH_MARKED_RE.test(key)) return; | ||
|
||
const objPathStr = key.replace(FILEPATH_MARKED_RE, ""); |
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.
const objPathStr = key.replace(FILEPATH_MARKED_RE, ""); | |
const inlineObjPathStr = ObjPath.stringify(parts).replace(FILEPATH_MARKED_RE, ""); |
I know a layout json object is currently a flat object (i.e. 1 depth), but I think it'd be good to consistently use the ObjPath
helper here so we can extend to support a nested layout object in the future.
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.
Here's the commit where I improves this part of the code with all the nits you said: #233
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.
One last thing on the validateExtractedFilePath
function signature, but otherwise this looks good to go - thanks @francoborr!
src/lib/marshal/shared/helpers.ts
Outdated
export const validateExtractedFilePath = ( | ||
val: unknown, | ||
sourceFileAbspath: string, | ||
sourceJson: string, |
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.
sourceJson: string, |
In checkIfValidExtractedFilePathFormat
, we refer to sourceFileAbspath
as the abspath to the json file, so I would say we match that here as well?
Taking the directory context abspath and the json file name separately like you've done here works also, but in that case we probably should name change sourceFileAbspath
arg above to something different like, dirContextAbspath
. Otherwise we have the same name vars that hold/mean something different.
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.
Got it! 48743fa
Description
Adds a
layout pull
command for pulling a given email layout into a directory. It also allows to pull all email layouts from a given environment using the--all
flag along with the--layout-dir
.It allows the following flags:
This PR also abstract some logic we use for reading external field contents. Before we used this logic when pulling
workflows
, but now we use the same logic for pullinglayouts
.Tasks
KNO-4367
Video
https://www.loom.com/share/d0035467d1cf48a999536b466d5dd1df