-
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
Run install and pack when fetching git dependencies with a prepare script #3553
Conversation
The algorithm specified seems to be right. Just make sure all the relevant lifecycle scripts are being run in the same order and such. |
Tests updated, and I think they pass. (The master branch builds are failing, so I don't know how confident I should be about the tests) |
package.json
Outdated
@@ -37,6 +37,7 @@ | |||
"strip-bom": "^3.0.0", | |||
"tar-fs": "^1.15.1", | |||
"tar-stream": "^1.5.2", | |||
"test-js-git-repo": "https://github.com/Volune/test-js-git-repo", |
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.
not on npm?
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 dependency needed?
src/cli/commands/install.js
Outdated
@@ -842,7 +846,9 @@ export async function wrapLifecycle(config: Config, flags: Object, factory: () = | |||
await config.executeLifecycleScript('postinstall'); | |||
|
|||
if (!config.production) { | |||
await config.executeLifecycleScript('prepublish'); | |||
if (!config.gitDependency) { |
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 it is better to name it more generic disablePrepublish
Thanks, @Volune, this looks legit and well thought through. |
I cleaned the code according to comments, and rebased, so tests are passing now. Let me know if anything is missing. |
Great work, @Volune. |
I'll look into it. It will take some time, I'm not used to writing. |
@bestander @Volune just checked out the new feature, and I'm wondering what your recommendation is for the following setup given the new functionality:
When installing the dependencies of When I change to the temporary directory where the build is supposed to be happening before packing, it appears the Here's the output just for reference:
Could this be related to #2053? I thought best to continue the discussion on this PR since it's recent and relevant, but I can create a new issue to house the discussion if you'd like. |
@sammarks I can reproduce. I will prepare a PR with a fix and improved tests. @bestander Do you or another contributor with good knowledge of the |
Hello! I just published a tool to create git tags for packages with build steps and monorepos packages https://github.com/ramasilveyra/gitpkg, my intention is to create very lightweight git tags that don't delay the install command and also be able to publish the gitpkg packages to the same repo. Please if you want let me know what do you think about this approach. Thanks! |
This is pretty cool @ramasilveyra! Looks like a nice alternative until we can nail down this issue. |
@ramasilveyra that looks exciting. |
@sammarks Sadly they are not the same 🙁 the approach choose by npm and yarn is to run the build scripts when you install the git dep, this could increase a lot the installation time. And it doesn't work with lerna git tags.
The end result is a git tag with only the files needed, look at this https://github.com/ramasilveyra/public-registry/tree/gitpkg%401.0.0-beta.0-gitpkg @bestander I believe that there is a lot of wins if the functionality of gitpkg gets integrated in yarn, npm and lerna/workspaces.
Is this something for a RFC? Is there a common place to discuss this ideas to get implemented on npm and yarn? |
@ramasilveyra, yes an RFC would be the right way to go. |
@Volune Doing |
@masaeedu - I was just looking into a similar issue, in my case it turned out that the logic added in this PR only applies to |
@masaeedu @rwjblue |
When a prepare script is defined, npm and yarn will build uppy automatically if it's being depended on through a git URL. This is useful when downstream projects don't want to wait for the next release to be tagged. See npm/npm#3055 (comment) See also yarnpkg/yarn#3553
Implement a new behaviour in
GitFetcher
to fix #2875 and match the new behaviour of npm 5 regarding git dependencies:install
command in that folder, excluding the prepublish scriptpack
command and use the content of the generated tarball as result of GitFetcher(@zkat please let me know if you think it differs from npm)
At the moment, I open the PR mostly for review and comments. The PR still lacks documentation of the new behaviour.
Some implementation details:
config.gitDependency
to disable the prepublish scriptpack
code. That means all the files are in apackage/
folder. If generated fromgit archive
, there are nopackage/
folder. To differentiate during the tarball extraction, when I generate a tarball from thepack
command, I add a parameter in the header of the first file.tarballMirrorPath
filename does not have extension. ThetarballCachePath
filename has extensiontgz
, but the content does not seem gzipped. I did not change these points.git archive
may be run multiple times for one fetch. I replicated this behaviour, running thepack
command multiple times. I did so to ensure a better error handling with minimal work. I think both cases can be optimised.I added only one test. I'm thinking of improving it to ensure the prepublish script is not run.
I'm not sure what other tests are worth adding, while staying in the scope of this PR. (I don't want to fix all git-fetcher issues here).
By the way, if yarn supports a "git+file://" protocol, that would be useful for testing.