-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Change Yarn detection to look for lockfile #138
Conversation
Re: 1, I think removing the exception handling would be a nice cleanup if you have the time Re: 2, Another test with an actual file for yarn.lock is a nice-to-have Re: 3, I think failing if yarn is not installed but yarn.lock is committed is fine, but we need to add an "out" for people who for some reason have a yarn.lock but would like to use npm. A configuration option to force use of npm or yarn, maybe. (But I wouldn't necessarily block this PR on that) |
Can this check for yarn installed as well as yarn.lock? That way CI servers that don't have yarn won't start breaking with this change. |
@backspace Thanks for working on this. After thinking it through and chatting with @kellyselden and @rwjblue, we'd like to make use of yarn be only through opt-in via the config ( Are you interested/willing/do have time to take this PR in that direction? |
I’m into replacing this with the plan you detailed. Do you think that maybe the presence of I should be able to try getting into this direction later this weekend or during the upcoming week. I did have a mysterious CI failure in my work on this to date:
There’s a comment within the test specifically addressing it:
It was confusing to me because I didn’t think I had changed anything related to using the stub. But hopefully this error will disappear as I change things around with the current plan 🤞 |
I think that approach w/ just yarn.lock is reasonable, since it'll just be a warning. Thanks for continuing this work even though we changed the plan out from under you. Re: CI failure, most of the time that comment is true. I haven't seen that test be flaky before, but it's possible. If it doesn't go away, I'll look into it more. |
hah I totally believe it, I probably changed something I didn’t realise would affect it. Regarding this:
Am I correct in understanding that this is in the
Or is it meant to go elsewhere? |
@backspace It would be top level outside scenarios: module.exports = {
useYarn: true,
scenarios: [
{
name: 'test1',
bower: {
dependencies: {
ember: '1.10.0'
}
}
},
{
name: 'test2',
command: 'ember test',
npm: {
dependencies: {
'ember-feature-flags': '3.0.0'
}
}
}
]
}; |
ah, makes sense, thank you! |
5b38735
to
7fd94ae
Compare
This is no longer needed because useYarn is what matters, not the presence of the yarn command.
This needs to be directly passed into the adapter constructor in the tests, as it is in the code.
I have some progress on this. Here’s a screenshot of the warning: The wording can of course be adjusted. Should it be coloured differently? I see elsewhere there’s I added It feels a bit unsatisfying to have no testing around the If there’s anything you think should be added or changed, let me know! ETA: hmm an obvious oversight is updating the |
Re: Re: testing for log, I've done it elsewhere. Here is an example: https://github.com/ember-cli/ember-try/blob/master/test/tasks/try-each-test.js#L138 Alternatively, you could refactor the check into a method that returns based on whether the yarn check passed or failed, and only write the console output based on that. It would allow you to unit test the yarn check without testing the output. Also, 😀, thanks for the work and the detailed writeup! |
Thanks for the example of log testing and general ongoing input 😀 What do you think of the Yarn check happening in |
The DependencyManagerAdapter should only be created once whether running try:one or try:each. I think it's better in the npm adapter because the check should only happen when there are scenarios with npm changes. |
I should have realised why these weren’t in use elsewhere 😝
test/tasks/try-each-test.js
Outdated
@@ -264,10 +264,12 @@ describe('tryEach', function() { | |||
}); | |||
|
|||
writeJSONFile('package.json', fixturePackage); | |||
fs.closeSync(fs.openSync('yarn.lock', 'w')); |
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.
Is this preferable to fs.writeFileSync
?
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.
hah! I just copied from Stack Overflow 😳 but I guess writeFileSync
is newer than that answer! I’ll replace with that. 😀
hmm well the answer is from 2012 but that method has been around since Node 0.1.29 🤔 … I just searched for “node touch file” and used that. anywayyyyy
@backspace Just had the one question in the test, otherwise LGTM and I'll merge once you reply. Thanks again for all the work & updates. |
Thanks to @kategengler for letting me know about this!
Thanks for the change! I'll merge as soon as CI passes. |
Excellent, thanks for the guidance! |
Great work everyone 🎉 I love it when I go looking for something I need and someone has put the work in 😄 How do I get this right now? Looking at the module I'm working on it doesn't seem to depend on ember-try directly, I'm assuming that's because now it's a default dependency of ember-cli? If I added the the github version of ember-try to my package.json would this work or do I need to wait until there is a version released and ember-cli depends on that version? Not trying to rush anyone just curious how I can make use of this new awesome 😂 |
When I was trying workarounds, I found that putting |
thanks @backspace that did indeed work 👍 |
Released in v0.2.17 |
This is a naïve fix for #133. It would seemingly work to merge, but I’m not sure if more nuance is needed, or whether the change should extend further.
I made use of
throw
because it was the minimal change, since that’s whatexecFileSync
would do whenyarn --version
failed. I could instead strip out the exception handling and directly use the simple boolean check ofisFile()
.The existing test for this doesn’t really exercise things fully, it mocks
_runYarnCheck
. Would it be worth using a trueyarn.lock
for testing?What happens if a
yarn.lock
is detected butyarn
itself isn’t present? Should theexecFileSync
perhaps remain? 🤔Let me know your thoughts and I’m happy to improve this. Thanks for
ember-try
, it’s endlessly useful!