-
Notifications
You must be signed in to change notification settings - Fork 122
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
yarn-support #488
yarn-support #488
Conversation
src/utils/require-template.js
Outdated
} | ||
ocTemplate = require(localTemplate); | ||
} catch(err) { | ||
ocTemplate = getOcTemplate(template); |
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.
this is the only "new" code I've added that tries to fix the yarn issue.
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.
Sorry about my ignorance, but how can that change affect over the yarn installation behavior? I only see you moved the logic to a function 😕
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.
Hi,
Yes I moved the logic into a function but I've also added an additional check of getting the template by name (line 35).
Try to do this: install OC globally w/ yarn and make sure your publish doesn't work. Then replace require-template.js in the yarn OC global folder w/ the file I've changed and see if that fixes. Thanks!
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.
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.
this is another problem; you need to rm -rf node_modules first, it is a known issue w/ npmlog when switching between npm and yarn 😢
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.
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.
infinite-loop-loader
tells us everything hehehe 😊 feel free to collaborate on this branch; I will not be able to follow this issue as I'll be offline for a couple of days but either @matteofigus or @nickbalestra should be able to have a look at this.
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.
After manually installing infinite-loop-loader
(ofc only for this test) everything works as expected! 😃
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.
very good; we are getting there 😉 thanks for your help!
// cc @matteofigus @nickbalestra
@matteofigus @nickbalestra @elboletaire not sure if we decided how to proceed w/ this issue; |
@matteofigus shall we have a conversation and decide how to proceed w/ this? // cc @nickbalestra @elboletaire |
@mattiaerre sorry for taking long to reply to this. Unfortunately requiring by name doesn't work. You want to require the template from the CLI local to the component. Requiring by name requires it local to the CLI, which happens to work currently for the jade/handlebars ones, but that will change soon in favour of taking those two off from the CLI (making the require by name attempt basically not useful). Now, getting back to the issue. I am not very expert about yarn, but this seems to be a yarn problem to me. There is a package.json, yarn is not installing all the deps during the install, so I would open a issue in their repo rather than here. |
@nickbalestra please can you review what I just said makes sense? lol |
return require(path); | ||
}; | ||
|
||
module.exports = function (template) { | ||
let ocTemplate; | ||
const localTemplate = path.join( |
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 need to understand, in case of yarn install, why this doesn't work. The oc-template-jade module must be there if yarn installed everything correctly, if it is not we need to find out where it is
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.
Same for the infinite-loop-loader. It should be in the node_modules.
Ok...I apology for previous comments. Now...If I go in that node_modules folder, it's pretty empty. The main reason, is that if I go 1 level down ( So, in conclusion, I believe @mattiaerre's approach in this PR is correct and will fix. |
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.
@mattiaerre I am ok with the approach.
Before merging:
- I prefer not including the yarn lock file. I am ok supporting yarn, but I would remove the lock file
- I am not sure about the jest tests here. We have another PR to discuss and I am personally happy about it, but for limiting this PR's scope my preference would be not to use jest. Feel free to disagree...as said, I have mixed feelings, we need to start with something at some point.
+1 to what @matteofigus said about the And I also think that, if we don't currently have testing, we should not merge issues. Let's add a new issue for adding tests. Given the moment, @mattiaerre will be able to cherry-pick the changes from his branch to the new PR. |
thank you for your feedback @elboletaire I adapted my tests to use mocha and it looks like I've been able to achieve the same result w/o Jest (although no snapshots, unfortunately); apart from that I think that this is a decent refactoring so as long as we are good w/ a quote from @ericelliott
source: twitter // cc @matteofigus @nickbalestra |
Nice quote 👍 It now LGTM. If it's good for you too, @elboletaire, can you merge? Thanks |
Done @matteofigus. Thanks for the fix @mattiaerre !! |
@elboletaire thank you! |
Description
see #487
get template by name
fix test
I've added a require by name step before the existing require by path ones; I've also added some small refactoring. I've tested this fix locally and it looks like it works w/ both npm and yarn.
Coverage report