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

feat(config): use XDG config specification #3674

Closed
wants to merge 2 commits into from
Closed

feat(config): use XDG config specification #3674

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 19, 2017

As per XDG Base Directory Specification, prioritise the environment variable $XDG_CONFIG_PATH when possible, and use $HOME/.config/ as a fallback.

Backward-compatibility is handled to avoid unnecessary breakage, this is a first step towards full compliance with the spec.

Related to #2334 (But only solves part of it)

@bestander
Copy link
Member

The only concern is the extra clutter, can we have it in one place?

@ghost
Copy link
Author

ghost commented Jun 30, 2017

Do you mean between the two registry files?

I tried to put everything in YarnRegistry but it felt hackish to repeat parts of getPossibleConfigLocations to keep it contained there. And using a yarn directory inside the NpmRegistry file felt even more wrong. I can certainly modify the constructor to include the name, but that feels strange to say the least. I could use an internal name field in both classes instead. That'd still require some changes in both classes, but would keep things cleaner than the empty string hack. What do you have in mind?

src/util/rc.js Outdated
@@ -49,6 +49,7 @@ export function findRc(name: string, parser: Function): Object {
}

if (home) {
addConfigPath(process.env.XDG_CONFIG_HOME || join(home, '.config', name, `${name}rc`));
Copy link
Member

Choose a reason for hiding this comment

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

not clear why process.env.XDG_CONFIG_HOME OR home/.config is used now

@@ -41,7 +41,7 @@ export default class YarnRegistry extends NpmRegistry {
constructor(cwd: string, registries: ConfigRegistries, requestManager: RequestManager, reporter: Reporter) {
super(cwd, registries, requestManager, reporter);

this.homeConfigLoc = path.join(userHome, '.yarnrc');
this.homeConfigLoc = process.env.XDG_CONFIG_HOME || path.join(userHome, '.config', 'yarn', 'yarnrc');
Copy link
Member

Choose a reason for hiding this comment

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

Why process.env.XDG_CONFIG_HOME can't define userHome or config.userConfig

Copy link
Member

@bestander bestander left a comment

Choose a reason for hiding this comment

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

The problems are:

  • we have multiple places that define from which folder the config will be read and reading it from process.env.XDG_CONFIG_HOME in a few places makes it even harder to reason
  • I think we need a basic e2e test for this feature to make sure this won't regress

Only add paths where needed, keeping all possibilities that were offered
before
@ghost
Copy link
Author

ghost commented Jul 4, 2017

The change should be far less intrusive now. I'll look at how e2e tests are done when I have some time to dedicate to this.

@bestander
Copy link
Member

Yeah, that is way better, thanks @Michael-Zapata.
Waiting for tests.

With `~/.yarnrc` being the historic location, breakage should not occur
for current users
@bestander
Copy link
Member

Thanks, @Michael-Zapata.
end_to_end_tests/data/run-yarn-test.sh is not the best place for very specific e2e tests, this script is hard to monitor and debug on CI and it is not really scalable.

Can you express the test similar to this d709c2f?

@ghost
Copy link
Author

ghost commented Jul 5, 2017

I pushed to see if results were different in the CI, but that test is failing in local, as in both checks. I can get behind one of them failing, but the two of them seems rather strange.

I should dig further before doing tests as this is obviously not working. :)

@BYK
Copy link
Member

BYK commented Jul 25, 2017

@Michael-Zapata the CI seems fine. Do you need to work on this still or can we merge?

@bestander any more concerns about this PR or do you think it is ready?

@ghost
Copy link
Author

ghost commented Jul 26, 2017

Hey, sorry for not getting back on that. The test that was added isn't running in the CI from what I can see, as it fails completely locally. I didn't have the time to take a look at why it's failing and that should be fixed before merging as this is not functional at the moment.

@BYK
Copy link
Member

BYK commented Jul 26, 2017

@Michael-Zapata alright, how can I assist you with that? :)

@ghost
Copy link
Author

ghost commented Jul 27, 2017

I just need to investigate to understand why this isn't working, I am not really familiar with the codebase and I won't have the time to do that before this week-end. :/

Some pointers on where this might fizzle would be very much welcome though!

@BYK
Copy link
Member

BYK commented Aug 2, 2017

Some pointers on where this might fizzle would be very much welcome though!

I don't know that end-to-end script either so can't really help quickly :( That said once I have time to get back to this, I can help if you don't beat me to it :)

@HaleTom
Copy link

HaleTom commented Oct 7, 2017

Any chance of moving the node_modules directory to $XDG_DATA_HOME?

@bestander
Copy link
Member

Some time has passed, let's close the PR as there are too many conflicts.
If anyone wants to reopen a new one please go ahead.

@bestander bestander closed this Oct 17, 2017
@bestander bestander mentioned this pull request Jan 8, 2018
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

3 participants