Skip to content
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

refactor: New naming of Settings #284

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

jwikman
Copy link
Owner

@jwikman jwikman commented Feb 14, 2022

This is a proof of concept of how we could refactor the naming of our settings.
The first one out was a boolean setting. Next up is a string setting

Thoughts?

@jwikman
Copy link
Owner Author

jwikman commented Feb 14, 2022

@theschitz have a look at this to see if this is a plausible way forward?

Comment on lines +69 to +70
public documentationOutputIndexFile = false;
public documentationOutputIndexFileDepth = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could documentation be it's own class or interface? Having the object grouped and structured similar to package.json would be nice IMO. But is it practical?

Copy link
Collaborator

@theschitz theschitz Feb 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would mean to access the property it would be like this:

const settings = new Settings("my/workspace/folder");
if (settings.documentation.outputIndexFile) {
     // propably output index file.
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea! 👍

Will play with that later

I think it's a good thing to not rush through this change, so I think this PR will be active some time with some small changes now and then...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played a bit with this, and this approach would break the SettingsMap and SettingsLoader logic... :/

  settingsMap.forEach((propertyName, settingName) => {
    const configuredValue = config.get(settingName);
    if (configuredValue !== undefined) {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      (settings as any)[propertyName] = configuredValue;
    }
  });

Copy link
Collaborator

@theschitz theschitz Feb 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of the top of my head and a bit naive perhaps but would this work? We could also rebuild the settingsmap I guess?

 settingsMap.forEach((propertyName, settingName) => {
     // propertyName.split('.')[0] would be "NAB" (?)
     const groupName = propertyName.split('.')[1];
     propertyName = propertyName.split('.')[2];
    const configuredValue = config.get(settingName);
    if (configuredValue !== undefined) {
      (settings as any)[groupName][settingName] = configuredValue;
    }
  });
  • edit had a look in the code and updated the vars used.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are welcome to test that out! 🙂

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.

None yet

2 participants