-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[feature] [may break .yarnrc for older versions] Ability to pass command CLI arguments via configuration in .yarnrc #3033
Conversation
src/rc.js
Outdated
'mutex', | ||
|
||
'no-emoji', | ||
'har', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should keep the list of synced args and .yarnrc properties?
I wonder if we can make it a dynamic setting that would be generic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been wondering the same thing, but I'm a bit worried about the potential effects of letting the users put any argument into their rc files :/ For example, --force
in the yarnrc seems like a bad idea.
How about having a 'flags' section there or maybe prefixing all flags, e.g.
'argument-flag-force: true'?
…On Tue, 4 Apr 2017 at 10:36, Maël Nison ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/rc.js
<#3033 (comment)>:
> + 'no-lockfile',
+ 'pure-lockfile',
+ 'frozen-lockfile',
+
+ 'no-bin-links',
+ 'link-duplicates',
+ 'flat',
+
+ 'cache-folder',
+ 'modules-folder',
+ 'global-folder',
+
+ 'mutex',
+
+ 'no-emoji',
+ 'har',
I've been wondering the same thing, but I'm a bit worried about the
potential effects of letting the users put any argument into their rc files
:/ For example, --force in the yarnrc seems like a bad idea.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#3033 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWJBHumGtvSnHzBe2ioTFVmDor0Rtks5rsg8ZgaJpZM4MxuIN>
.
|
It makes sense for most of the other parameters to be used as-is (for example, I'd prefer to write |
Consider how this feature will be used in the long term and also how you
will handle collisions.
For example, there might be a setting that is named the same way as a flag
in one of the commands.
…On Tue, 4 Apr 2017 at 10:51, Maël Nison ***@***.***> wrote:
It makes sense for most of the other parameters to be used as-is (for
example, I'd prefer to write cache-folder rather than
argument-cache-folder). But maybe we could only prefix a few parameters
(on the top of my head, --force, --verbose, --json) and let the other
ones be used without requiring such a prefix.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#3033 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWMaTsNAv5d1fk4_j0PNlWW4Tp7z1ks5rshKcgaJpZM4MxuIN>
.
|
Shouldn't that be avoided? Even if arguments are stored in a separate "namespace", it sounds confusing to have two similarly named keys that unlock two different behaviors. My initial approach was to consider that semantically speaking, nothing prevented the values stored in an rc file from being specified as a command line argument (in fact, the default behavior of the |
Yeah, that actually makes sense.
Thanks for thinking it through.
I'll let you decide on that part as long as we don't have to hardcode every
new argument that needs a default value via rc file.
|
A few use cases to consider:
|
I was thinking about a syntax:
Basically, all command line flags would be prefixed by The main issue is that I don't find it very pretty ... Would probably be better if the yarnrc file was written with YAML or similar. |
I like it!
|
Should be mostly fine, I'm waiting for the tests. The only issue I had is that the |
src/rc.js
Outdated
@@ -0,0 +1,87 @@ | |||
/* @flow */ | |||
|
|||
import rc from 'rc'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we use require() for npm dependencies
I think you don't need to bother about paths relative to .yarnrc. |
This may be true if only yarn is run in the process, but not if yarn is used programmatically as part of an application. Blocking the whole app seems very dangerous in that scenario. I would appreciate it if you could keep this use case in mind for future improvements. |
I'm not sure I see what you mean - do you have an example in mind? |
You can install and |
I think we need to improve Yarn require-ability for programmatic use. |
Summary
This PR opens the way to share configuration between multiple projects via the use of the
.yarnrc
files. The current design it pretty simple: it simply adds the supported options from the yarnrc file at the beginning of the command line.
Syntax
Adding the following into a yarnrc path in your cwd or any path above will automatically add the check files option when running
yarn install
(but not any other command).When the command name is missing, the argument will be added to every command you call. For example, the following will change the cache path everywhere:
Since the arguments are added at the beginning of the command line, every argument you manually specify when calling the binary will override the yarnrc-providen ones. For example:
Notes
The yarnrc files are extracted starting from your current working directory - not the package.json directory.
The yarnrc is currently parsed synchronously. I believe this is not an issue, since it's quite literally the very first thing we need to do when booting the application (even before the command line can be parsed), so there's really nothing we could run concurrently anyway.
The yarnrc is read in another file (https://github.com/yarnpkg/yarn/blob/master/src/registries/yarn-registry.js). I haven't changed how it works there, since I wanted my first draft to have as few changes as possible, but it's something that should probably be fixed so that the code only use one path to manage the yarnrc files.
Test plan
I still have to write a test to be sure that it works as expected, but the existing ones don't break.