[NPMCLI-4] Improve yaml modifications Created: 05/Apr/16 Updated: 04/Nov/16 Resolved: 28/Apr/16 |
|
| Status: | Closed |
| Project: | Magnolia CLI |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.0.1 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Tomáš Gregovský | Assignee: | Aleksandr Pchelintcev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | npm | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 3.75d | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Date of First Response: | |||||||||
| Sprint: | Basel 41 | ||||||||
| Story Points: | 5 | ||||||||
| Description |
|
scripts which are editing yaml configuration (e.g. add-availability) right now they take yaml code, transform it in to json, add/edit whats need and transform back to yaml. unfortunately during first transform from yaml to json, what doesn't looks like json is removed, so all comments '#...' or includes '!include' etc... ale lost during this edit. potential fixes: |
| Comments |
| Comment by Christopher Zimmermann [ 11/Apr/16 ] |
|
In the world of NPM and GULP there are lots modules that operate on JSON, which makes sense since these are javascript focussed tools. Some possibilities:
Big advantage of option 1 is that then all the existing npm libraries that use "js-yaml" will work out of the box. But of course it's bad that we have to change our syntax. - On the other hand, there's plenty of other advanced YAML syntax that is probably not going to be handled well in any transformation to JSON. |
| Comment by Aleksandr Pchelintcev [ 13/Apr/16 ] |
|
I did some research on the topic today and here're some thoughts: The current solution which does Yaml->JSON->YAML conversion is indeed flawed since:
A possible solution is to handle this with decorators, but:
One possible solution is to do the following:
Such trick would require some customisation of Yaml parser/composer that would help us to track the node names (probably doable, but not trivial task). Provided we can resolve the injection point then - it should be trivial to do the rest. Good thing here that we don't do actual Yaml conversion to anything, only parsing/serialising operations, which are lenient to the unknown tags. |