-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: register custom formats take 2 #6205
Conversation
Format will have the same behaviour as the widget property
@erezrokah any ideas why cypress is failing? I wasn't able to run them myself and don't have permission to download screenshots. |
Looks like our tests started failing with a specific renovate PR https://github.com/netlify/netlify-cms/actions/workflows/nodejs.yml?query=branch%3Amaster. Looking into it |
@erezrokah using |
You're correct. I don't think the failure is related to your changes. However I'd prefer to fix the tests before merging this PR. |
@erezrokah thank you for helping get green! It says there's one workflow awaiting approval. Anything else I should do to get this over the line? |
That's GitHub's crypto mining defense technic :) First committers need approval from a maintainer to run the CI. I'm trying to think of a way to avoid manual initialization. We could have the custom formats defined as top level item It will also make it clear what's supported |
I'm not sure - wouldn't some custom javascript have to run to register the formatter implementation? Where would netlify-cms know where to find that javascript if there's no manual initialization. Also - I don't feel very comfortable adding non-manual initialization support since the team have been using it since day one. Would you be open to it going in without, then if there are users requesting custom formats without wanting to manually initialize, a separate piece of work could be done to support that use case too? (Selfishly - that wouldn't help my team and we would love to be able to use this now!) |
Thanks for your input @mmkal, what concerns me is that the CMS default is not to have manual initialization so requiring it here breaks that. Also other Another option is to drop the static config level schema validation and only validate dynamically when trying to retrieve the format. We do the latter for custom widgets and display an "Unknown" widget when that happens. WDYT? |
I'm not sure I agree it breaks that. The default setup still doesn't require manual initialisation - it's only required if you want to start pretty seriously customising the behaviour by adding extra file formats. Having said that, I can't see why it needs to be any different from registering a custom widget.
I think this is already happening thanks to this change: If someone tries to use an un-registered widget, there will just be an error thrown. So maybe this is already meeting the requirements? Is there a simple way to test this with a non-manual-initialized setup? |
@bytrangle @krider2010 @erezrokah fixed the prettier problem - hopefully ready now but won't know til the build is approved! 🙏 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I still want to merge this! |
✅ Deploy Preview for decap-www ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
…fy-cms into mk/custom-formatters
@martinjagodic the only thing failing (after a year and a half of "Update from main and cross fingers") is I really don't think it's related - could we merge this as is? I've updated to incorporate all the |
* feat: register custom formats * fix: register custom formats validation * fix: change 'format' field validation to string instead of enum Format will have the same behaviour as the widget property * test: custom formats and register function * docs: explain usage and note manual initialization requirement * fix: remove unused imports * use default extension * remove manual init note * PR comments * fix: prettier * revert unnecessary changes? * chore: more revert? * chore: newline * chore: update import --------- Co-authored-by: Jean <jlabedo@gmail.com> Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com> Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
* feat: register custom formats * fix: register custom formats validation * fix: change 'format' field validation to string instead of enum Format will have the same behaviour as the widget property * test: custom formats and register function * docs: explain usage and note manual initialization requirement * fix: remove unused imports * use default extension * remove manual init note * PR comments * fix: prettier * revert unnecessary changes? * chore: more revert? * chore: newline * chore: update import --------- Co-authored-by: Jean <jlabedo@gmail.com> Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com> Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
* feat: register custom formats * fix: register custom formats validation * fix: change 'format' field validation to string instead of enum Format will have the same behaviour as the widget property * test: custom formats and register function * docs: explain usage and note manual initialization requirement * fix: remove unused imports * use default extension * remove manual init note * PR comments * fix: prettier * revert unnecessary changes? * chore: more revert? * chore: newline * chore: update import --------- Co-authored-by: Jean <jlabedo@gmail.com> Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com> Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Replaces #5839
Fixes #5848
Summary
Adds the ability to register custom formats (could be xml, po, binary, json5, etc.).
Also adds the requested tests and docs from the last PR (1dc43db + 6d29b23)
Test plan
Unit tests for register function + formatters themselves. Then ran manual tests by doing
npm pack
, installed the.tgz
file directly in the project we're using netlify-cms with, then registering some custom formats... and it worked.Checklist
yarn format
.yarn test
.