-
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
Allow subdirectories within git repos in yarn install #4725
Comments
There are a couple of good ideas for syntax to use to specify subdirectories in the linked issue (npm/npm#2974) Use pip's way of using a query parameter Use |
Another idea: |
That might be ambiguous depending on how the git server urls are setup. The url might be something like
Then it become hard to say what is part of the repo path and what is the subdir_path |
Not sure if this applies to every repo, but with Github both Regardless of syntax it would be nice to have this feature either way. It would be cool to make the syntax intuitive though :). |
Oh yea, I was mostly talking about other website, not really github. Sorry my example wasn't the best one to explain it. |
Long discussion about supporting this in npm: There are some suggested separators in the thread. |
I would also like to be able to do this to facilitate working with a monorepo that contains a lot of sub modules. I also found #1570 which discusses this. That was closed in favor of https://github.com/yarnpkg/rfcs/issues/15 but https://github.com/yarnpkg/rfcs/issues/15 doesn't exist anymore so it's hard to tell what if anything was done or decided there. |
so |
Yeah, rising popularity of monorepo architectures makes it a crucial feature. Is there any workaround for this, for now? Discussion about public API tend to be years long... |
My # 1 use-case for this is pulling in bug-fixes from monorepo's that haven't been merged or released yet. I often want to keep most of the original packages, but pull in one of the sub-repos with a bug-fix. Currently I am unable to do this, and the workarounds are complex. Being able to reference a Github branch would greatly lower the resistance. I know there are some people at npm that are highly resistant to the idea of this, and monorepos in general. However, many of the contributors here work on projects that use monorepos. I would suspect that if yarn were to implement this feature and it became popular enough npm would follow suit. A lot of yarn ideas have been implemented in npm later on. yarn to me is the babel of npm. |
@erykpiast couple workarounds that I can think of:
Or -- this is maybe even crazier -- add the remote in question as a submodule and (optionally move your project files into a subdirectory) then use yarn workspaces? Disclaimer: I haven't tried either of these approaches and they both add overhead for new developers & your CI builds... |
I can confirm this works. Upgraded to webpack 4. Create React App doesn't have support yet but there's a PR that's waiting to be merged - unfortunately webpack 4 has changed it's plugin API. Doubly unfortunate: create-react-app is repo containing multiple packages. Adding the forked PR as a submodule and adding the package using 'file:' syntax worked a charm. Literally saved an entire day or more of work with this work around. |
It's alarming that this isn't on the roadmap for either npm or yarn due to the rise in popularity of monorepos. The |
I agree. After a few months down the git submodule, Monorepo support would be a dream come true. |
yarn + lerna (using yarn’s workspaces) works to manage monorepos. |
A second tool to install from a monorepo isn't ideal. It should be as
simple as installing a package from a single package repo, using `yarn add
...`
In general, it doesn't help JS' 'little problem'. A use case comes up. We
use a new tool when an existing tool is the perfect home.
…On Sun, 1 Jul 2018, 11:34 p.m. Frederik Krautwald, ***@***.***> wrote:
yarn + lerna (using yarn’s workspaces) works to manage monorepos.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4725 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAjP2lWrm2u8tOiIZQ5D-oKre9BqTj5-ks5uCU6SgaJpZM4P7hjl>
.
|
@Frikki I don't believe lerna has much submodule support, and isn't a "consumption tool" anyways. @jwdunne For now I just |
Hello! I built https://github.com/ramasilveyra/gitpkg to "publish" packages from monorepos as git tags, it may help. |
@ramasilveyra that looks super useful -- thanks for the addition 👍 |
Some news in supporting git subdirs as install sources? Thanks, |
I missed these while cleaning up my last PR. Sorry about that. :-( Unrelated question: Do you have a predefined release schedule? I am working to get these changes integrated into our downstream project, and yarn makes it [a little tricky](yarnpkg/yarn#4725) until the package is published to npm. (I don't mean this to rush you; rather, I want to avoid feeling silly doing an extra workaround if you are about to publish it anyways.)
This may look a bit hacky at the beginning, but after some reasoning it seems to be a legitimate solution to the problem 👍 |
Seriously, gitpkg works! It creates tags inside the project repository, and can be used with repositories containing multiple packages. And this prompted me to ditch |
+1 |
Just used |
I built a service https://gitpkg.now.sh/ to download the sub folder of a git repo as a For example, if you want to add
also works for Note that I must say sorry to @ramasilveyra because my service's name conflicts with the tool he develops but I didn't know that before. |
@EqualMa This looks pretty amazing. I'll have a look at this soo. |
@EqualMa It'd be even more amazing if it works for projects with a build step. But anyway, great job, thank you so much! |
Do we still need gitpkg? Running latest lerna and when run in independent-mode it will publish git tags of each component. |
@erykpiast Finally GitPkg service supports custom scripts, allowing you to run a build step in postinstall or other scripts! You can checkout the docs or just try adding custom scripts at https://gitpkg.now.sh |
@EqualMa that's even more than awesome! Thank you! |
Any updates to this? Is it planned or anything? |
@EqualMa awesome! great job! |
I'm having an issue trying to fork a repo (https://github.com/ianstormtaylor/slate) that uses workspaces and has multiple packages in the same repo. I only want to modify and import one of the packages. Trying to
I've also tried to check in the published files, but my understanding is this is a problem with yarn looking a tar only found at the root directory of a github repo? So is the only way to fork a project that uses workspaces to use something like |
Just ran into exactly the same issue as @jason-krypton ... trying to work with a fork of a repo that uses workspaces, normally I'd just yarn add the forked git repository ... that's impossible now I guess? Wasting a decent bunch of time on this in order to change a couple of lines of code. :-( |
I have similar issues with ckeditor5. I'm trying out GitPkg now. |
So @LucidDan and others. I've found the following to work:
It's disappointing that there isn't a way to just have |
Implemented in v2, starting from Yarn 2.1: https://dev.to/arcanis/yarn-2-1-git-workspaces-focused-installs-loose-mode-live-playground-4kfc#workspace-cloning You can use the following syntax to install a specific workspace (not arbitrary folder):
|
yarn add https://gitpkg.now.sh/<user>/<repo>/<subdir>[?<branch>] OR
|
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Unable to install packages that are inside subdirectories in git repos. This is a very common case for monorepos and just repositories that can't have the node package in the root repo.
If the current behavior is a bug, please provide the steps to reproduce.
Not a but
What is the expected behavior?
There should be an availably syntax for
yarn add
andyarn global add
that allows to add packages that are inside subdirectories in a git repo.It make it much easier to use unreleased code when testing unreleased versions for issues/regressions or fixes that aren't live yet like this ticket microsoft/code-push#428
ex. packages affected by this issue
https://github.com/Microsoft/code-push/tree/master/cli
https://github.com/Microsoft/BotBuilder/tree/master/Node
https://github.com/facebook/react-native/tree/master/react-native-cli
https://github.com/babel/babel/tree/master/packages/babel-cli
Related npm issue: npm/npm#2974
Please mention your node.js, yarn and operating system version.
yarn versions v1.2.1
node version v8.7.0
macOS Sierra 10.12.6
The text was updated successfully, but these errors were encountered: