Skip to content

Conversation

@jj811208
Copy link
Contributor

@jj811208 jj811208 commented Nov 23, 2022

What's the problem this PR addresses?

closes #5090

What I did in #4982 did not handle SettingsType.ANY field

...

How did you fix it?

Implemented a function that converts a ResolvedRcFile tree into a value tree

example:

const foo = {
  changesetIgnorePatterns: [
    '/Users/jj811208/Sites/berry/.yarnrc.yml',
    [
      [
        '/Users/jj811208/Sites/berry/.yarnrc.yml',
        '**/*.test.{js,ts}',
        Symbol(),
      ],
    ],
    Symbol(),
  ],
  npmPublishAccess: [
    '/Users/jj811208/Sites/berry/.yarnrc.yml',
    'public',
    Symbol(),
  ],
  initFields: [
    '/Users/jj811208/Sites/berry/.yarnrc.yml',
    {
      author: [
        '/Users/jj811208/Sites/berry/.yarnrc.yml',
        {
          email: [
            '/Users/jj811208/Sites/berry/.yarnrc.yml',
            '[email protected]',
            Symbol(),
          ],
          name: [
            '/Users/jj811208/Sites/berry/.yarnrc.yml',
            'First Last',
            Symbol(),
          ],
        },
        Symbol(),
      ],
    },
    Symbol(),
  ],
};

const bar = getValueByTree(foo);

// bar
{
  changesetIgnorePatterns: ['**/*.test.{js,ts}'],
  npmPublishAccess: 'public',
  initFields: {
    author: { email: '[email protected]', name: 'First Last' },
  },
}

Use it where SettingsType.ANY is parsed

===

Additional Information:

Currently we have three types of trees

1. RcFile

user defined .yarnrc.yml

{
  a: 'a',
  b: ['b1'],
  c: {c1: 'c1'}
}

2. resolvedRcFile

generated after merging rcfile

{
  a: ['source','a',symbol],
  b: ['source',[['source','b1',symbol]],symbol],
  c: ['source',{c1: ['source','c1',symbol]},symbol]
}

3. configuration.values

  • resolve relative paths, resolve locators...
  • convert Object to Map (except SettingsType.ANY)
  • replace env variables
  • ...
{
  a: 'a',
  b: ['b1'],
  c: new Map([['c1','c1']])
}

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis merged commit 016c778 into yarnpkg:master Nov 24, 2022
@arcanis
Copy link
Member

arcanis commented Nov 24, 2022

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]: yarn init generates invalid entries in package.json starting from rc29

2 participants