Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Move execution of top level lifecycle scripts to install instead of postinstall#13259

Closed
palmerj3 wants to merge 5 commits intonpm:masterfrom
palmerj3:fixPreinstall
Closed

Move execution of top level lifecycle scripts to install instead of postinstall#13259
palmerj3 wants to merge 5 commits intonpm:masterfrom
palmerj3:fixPreinstall

Conversation

@palmerj3
Copy link
Copy Markdown
Contributor

@palmerj3 palmerj3 commented Jul 3, 2016

This appears to fix #10379

Could use some further testing.

palmerj3 added 2 commits July 2, 2016 23:08
…ostinstall

Change-Id: I17e28002d53937d07b90b210ffbcd8b5b1ca585a
Change-Id: I84d71d01809f20990f8ba08613b3b09df24aedc3
@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 3, 2016

The AppVeyor failure seems to be an issue with the CI server not having access to a git repo. Can you have a look and re-trigger? ping @iarna

@StWolf91
Copy link
Copy Markdown

StWolf91 commented Jul 4, 2016

I'll have to check tonight to be sure, but just in case I forget: Are you sure the top level lifecycle scripts don't include the postinstall script? Because just like preinstall should happen before install, postinstall should happen afterwards...

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 4, 2016

Yes it does include the postinstall script but it also runs build before hand..

What I can do is refactor topLevelScripts into two methods pre/post and run them before/after executeActions and that should be valid.

…the proper order

Change-Id: I9f7a709c1aada32e02c87514019480e4ddd2e2fb
@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 4, 2016

@DenianArthurShades I did a slight refactor, as mentioned, and now runTopLevelLifecycles is split into pre and post methods and executed in the proper order. Please let me know if you're able to test this. Thanks!

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 6, 2016

@seldo @iarna can you have a look?

…cript execution order and state

Change-Id: I995435e1aad586ce2a72291bf633f1256801686d
@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 7, 2016

Added a simple test to verify that lifecycle scripts are executed in the proper order and that node_modules does not exist (on a clean install of an app) on preinstall task.

Change-Id: Icc1d30545f259be281bf2eec5644cdb48a4aed3b
@iarna
Copy link
Copy Markdown
Contributor

iarna commented Jul 7, 2016

Thank you for putting this together. Unfortunately, this is, I believe, insufficient to the practical needs of a preinstall lifecycle. Specifically, my understanding is that some of the things folks want to be able to do include installing modules or otherwise modifying the tree before the installer starts. To do that, this needs to execute before the currentTree is loaded off disk, which is substantially earlier in the process.

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 7, 2016

@iarna ok what is required? Are we going off of what people want or some agreed upon spec?

I'll do whatever is necessary to get this bug fixed.

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Jul 7, 2016

@iarna also with this PR I am still able to install modules in the preinstall step...

@palmerj3
Copy link
Copy Markdown
Contributor Author

@iarna let me know your thoughts on this. I can take this further if necessary but thus far I think my PR works as expected.

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Aug 4, 2016

I would really appreciate a more thorough explanation here as to why this isn't adequate for merging... I'm willing to put in the time to make adjustments but the one comment I've received thus far is fairly ambiguous and is questionable whether it's even necessary.

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Aug 5, 2016

Last comment: I will just put this here that your own documentation says preinstall should only be used for compilation not for installing dependencies.. so I would really rather us not introduce feature creep into this and fix a bug that's existed the entire major version 3.

screen shot 2016-08-05 at 3 32 39 pm

@iarna
Copy link
Copy Markdown
Contributor

iarna commented Aug 8, 2016

@palmerj3 Thank you for your patience. I don't disagree with you per se, but it's not exactly installs people want to do here. I believe the main desire is to be able to setup symlinks in the node_modules that npm will preserve. The reasons I outlined previously are my summation of previous issues around this. Fixing this as you have would solve some but not all of the concerns folks have raised about the current behavior.

That being said, as I've thought this through more I think I'm inclined to say "no" to the "can read the node_modules AFTER preinstall time" because while that works fine for applications, it would be a disaster to implement for things being installed as dependencies, and I'm not comfortable having those two modes work differently.

To solve that need, I would prefer to have some application lifecycles that don't apply when you're working with something as a dependency. But obviously that's out of scope for this.

So on reflection I think I am ok with this as it is. Uh, sorry for taking so long to come around on this. =D I have a few minor tweaks I'd like to see in this PR, but they're small enough I'm happy to make them at merge time.

Comment thread lib/install.js
[this, this.debugActions, 'decomposeActions', 'todo'])
if (!this.dryrun) {
installSteps.push(
[this.newTracker(log, 'runPreinstallTopLevelLifecycles', 2)],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically: We don't need a new type of tracker, we can use runTopLevelLifecycles across both pre and postinstall lifecycles. Multiple completion trackers can be active simultaneously.

@palmerj3
Copy link
Copy Markdown
Contributor Author

palmerj3 commented Aug 8, 2016

@iarna ok cool! Let me know if you need me to make those changes.

@iarna
Copy link
Copy Markdown
Contributor

iarna commented Aug 11, 2016

This has been merged and will be in the next release (scheduled for later today).

@iarna iarna closed this Aug 11, 2016
iarna pushed a commit that referenced this pull request Aug 11, 2016
@zkat zkat mentioned this pull request Sep 22, 2016
4 tasks
@palmerj3 palmerj3 deleted the fixPreinstall branch December 17, 2016 22:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants