-
Notifications
You must be signed in to change notification settings - Fork 8
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
Layout support #8
Conversation
Also add some comments
error TS2345: Argument of type '(answer: { code?: string | undefined; }) => void' is not assignable to parameter of type '(value: unknown) => void | PromiseLike<void>'. Types of parameters 'answer' and 'value' are incompatible. Type 'unknown' is not assignable to type '{ code?: string | undefined; }’.
@@ -48,7 +48,7 @@ const cheatInput = (hideMessage: boolean): Promise<string> => | |||
choices: choices, | |||
message: hideMessage ? '\n' : title, | |||
}, | |||
]).then((answer: { code?: string }) => { | |||
]).then((answer: any) => { |
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.
For some reason specifying a type on the answer
value doesn't work in node 7.
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "postmark-cli", | |||
"version": "1.0.0", | |||
"version": "2.0.0", |
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.
I think this version bump is too high. First digit is reserved for major changes, we could probably go by something like 1.1.0 since there is a new feature being released.
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.
Ah, though I just noticed you introduced it due folder structure.
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 there a way to do this without breaking existing integrations? Perhaps putting the "layouts" folder inside of the root download folder, or specifying the type as "Layout" within the metadata.json for the template? I think there are probably some other benefits to not splitting them into separate folders at the root.
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.
I agree with not breaking existing integrations. Also my concern here is already having version 2 for app that is 1 month old. The feature is not that big in terms of CLI to justify that big change.
I do like though the folder split, since it follows the UI, and makes search through the list and separation easier. Although from what I see it would be easy to have them all in single folder since the name seems Alias based, therefore unique.
If we would like current new structure, there should be though an easy migration. All that would need to be done is check current folder structure (whether there is templates folder with subfolders) and provide a message to user that the files are migrated to new format.
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.
I agree that 2.0.0 is a huge bump for something so new, so I was reluctant about doing this.
We should still strive for separation between standard templates and layouts somehow to make layouts easy to find and avoid additional configuration in meta.json. I often find myself needing to quickly do spot fixes in the layout, so this would be helpful. I suggest that we go with Andrew's suggestion and just add a layouts folder to the list of standard templates in the root, so it's not a breaking change.
my-emails
├── _layouts
│ └── plain
│ ├── content.html
│ ├── content.txt
│ └── meta.json
└── password-reset
│ ├── content.html
│ ├── content.txt
│ └── meta.json
└── welcome
├── content.html
└── meta.json
The reason for the underscore in the layouts folder name is so that it's more likely to appear at the top of the list. It's also to reduce the likelihood that it will conflict with existing aliases.
Thoughts?
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 being flexible, @derekrushforth. I do think that as a convention, placing files in these folders
_layouts
, _partials
, etc. will be useful.
However, for a newcomer it may be non-obvious that the name of the folder is going to affect the type of template that gets saved. It also brings in another complication with moving templates, as changing the folder structure could cause the template type to change, which would be bad. If we think of each folder as being a "self contained" template, with all the info needed inside of it, maybe the problem gets easier...
By default, when we "pull" templates, this structure could work, but when "pushing" we're simply looking for directories that have the meta.json
, content.html
, and content.txt
files.
From there, meta.json handles any extra properties that need to be included, including type
, but the _layouts
directory is purely a default convention we provide, rather than a requirement to maintain template information.
It's certainly more complicated to resolve all of the templates when pushing/pulling, but this would give a lot of flexibility in the customer grouping these templates into sub-groups, etc on their end.
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.
@atheken definitely get what you're saying here. I like the idea of letting people change the folder structure to whatever they want, but yeah, this complicates things quite a bit.
My biggest concern is how we handle the process for pulling templates. We will need to figure out where each template is specifically located if they decided not to use our default folder structure.
I'm not so concerned about pushing, though. It's easier for me to rely on the template's metadata file instead of assuming template types based on the folder structure.
I'll give this a shot and let you know how it goes.
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.
I think the big take away for the moment is that we don't "move" templates to new locations compared to the 1.0 release and we should include the template type in meta.json
-- Standard
would be assumed when not set.
Beyond that, defaulting to using a "_layouts" folder for new layouts is a good option.
We can layer on the "make your own folder structure later."
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.
The code looks good @derekrushforth! I tested pulling/pushing templates + layouts and it worked perfectly.
@derekrushforth added base tests which should be good for release, for stuff like pulling layouts, pushing them with changes, etc |
Continue storing templates in root so that we don’t introduce breaking changes.
…ry structure - Read TemplateType field from meta.json - Ability to traverse any folder structure
Hey folks, I've updated the workflow based on the feedback. Here's a rundown:
Let me know what you guys think. If we're good, please approve the PR. |
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.
good to go @derekrushforth
Hey @ibalosh and @matt-west,
This pull request adds layout support to our
templates pull
andtemplates push
commands. Looking for whatever feedback you guys have about the code and changes to the workflow. I'd love to release this by EOD Thursday (6/27).templates pull
The folder structure downloaded from this command is a little different now. Templates and layouts are now organized into separate folders:
Changes to meta.json
There are a couple minor differences between the meta.json files for templates versus layouts.
LayoutTemplate
that lets people specify the layout alias being used for that particular standard template. It's not required. If users don't include this in thepush
command, we simply insertLayoutTemplate: null
into the API request. This ensures that the layout is not changed at all. If you want to remove the layout being used on a template completely, pass an empty string toLayoutTemplate
. This is how our public API works.Name
andAlias
are required. Does not include theSubject
field.templates push
This command now requires that the directory structure matches what you see above. Since this is a breaking change for anybody using the old version, I've bumped the major to
2.0.0
.Here's what pushing a template looks like now:
Tests
I've modified the tests a bit so they work with the new folders. The tests for the
pull
command also now check for an empty layout directory. This was only so I could get the tests to pass for now.@ibalosh, can you tweak these so that we account for layouts on the test server?
cc @rianvdm