This repository was archived by the owner on Aug 7, 2021. It is now read-only.
feat(hooks): improve hooks handling #961
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
fix(preuninstall): add preuninstall script to remove old hooks
During migration from one version to another or when the plugin is removed from application we need to remove its hooks. This is usually done in preuninstall script, however, it was missing until now. This causes several issues when the version is updated as old hooks remain, but they may not be valid anymore.
fix(postinstall): remove old hooks
As in 1.0.0 and CLI 6.0 we've changed the way nativescript-dev-webpack interacts with CLI, we need to remove hooks from previous nativescript-dev-webpack versions and use new ones. Usually this should happen with preuninstall script of the old version that removes the hooks. However, our current live version does not have such logic, so implement this in the postinstall of the current version.
This way we try to ensure the current plugin will work correctly.
feat(hooks): add before-checkForChanges hook
Add before-checkForChanges hook to prevent users from using the current version of the plugin with CLI 5.x.x or older. These two versions are incompatible, so add an error in case older CLI is used.
PR Checklist
What is the current behavior?
nativescript-dev-webpackhooks cause issues in different scenarios - the package does not remove its own hooks on preuninstall, so upgrading it causes issues as old hooks remain in the project.Also in case the new version of the plugin is used with old CLI, it fails with error
Cannot read property env of undefinedwhich does not give useful information to the user.What is the new behavior?
before-checkForChangesthat prevents users who have old CLI and the new version of the plugin (with bundle workflow) - we know this combination will not work, so throw a descriptive error message in this case.Fixes/Implements/Closes #[Issue Number].