acatton / serde-yaml-ng

Strongly typed YAML library for Rust, serde compatible. This is an independant continuation of serde-yaml from dtolnay.
MIT License
14 stars 1 forks source link

How to replicate a pnpm-lock.yaml with serde-yaml-ng #9

Closed SamTV12345 closed 2 hours ago

SamTV12345 commented 2 hours ago

Hi I'd like to write a package manager or already have a somewhat working package manager but I don't want to have a fight between pnpm and my package manager that is why I want to have my pm to also generate an identical pnpm-lock.yaml so that it doesn't matter which tool you use.

Do you know how I can insert custom newlines in my yaml. There are two edge cases:

Most of the things are separated by newlines:

yaml

lockfileVersion: '9.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

importers:

  .:
    dependencies:
      is-even:
        specifier: ^1.0.0
        version: 1.0.0
    devDependencies:
      eslint:
        specifier: ^7.2.0
        version: 7.32.0

and there is this resolution info that is for whatever reason inline

'@babel/code-frame@7.12.11': resolution: {integrity: sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==}

Is there some way to tell serde or your library to do this formating?

acatton commented 2 hours ago

Hi there,

serde-yaml-ng is the continuation of serde-yaml which was just a serde wrapper around LibYAML. LibYAML does the heavy lifting, I would recommend you read its code (or, more accurately, the transpiled version used by serde-yaml-ng) to get the answer to your question.

This is a bug tracker, not a support forum. I'll close this issue since, AFAIT, it's not describing any bug or unintended behaviour. Good places to get community support are stackoverflow.com and users.rust-lang.org.

Thank you for your understanding :)