yarn-plugin: import appropriate type to verify beforeWorkspacePacking signature
I realised that by default the `Plugin` type from `@yarnpkg/core` sets the type of the `hooks` property to `any`. This meant that there wasn't any restriction on the hooks that could be passed, and introduced the risk that a typo in the `beforeWorkspacePacking` name could lead to the hook being skipped. This commit pulls in the appropriate type for Hooks to verify the name and signature of the hook. Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
"@backstage/release-manifests": "workspace:^",
|
||||
"@yarnpkg/core": "^4.0.3",
|
||||
"@yarnpkg/fslib": "^3.0.2",
|
||||
"@yarnpkg/plugin-pack": "^4.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"semver": "^7.6.0"
|
||||
},
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { Hooks } from '@yarnpkg/plugin-pack';
|
||||
import { Plugin as Plugin_2 } from '@yarnpkg/core';
|
||||
|
||||
// @public (undocumented)
|
||||
const plugin: Plugin_2;
|
||||
const plugin: Plugin_2<Hooks>;
|
||||
export default plugin;
|
||||
```
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
import { Plugin, semverUtils, YarnVersion } from '@yarnpkg/core';
|
||||
import { Hooks } from '@yarnpkg/plugin-pack';
|
||||
import { beforeWorkspacePacking } from './handlers/beforeWorkspacePacking';
|
||||
import { BackstageResolver } from './resolver/BackstageResolver';
|
||||
|
||||
@@ -43,7 +44,7 @@ if (!semverUtils.satisfiesWithPrereleases(YarnVersion, '^4.1.1')) {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
const plugin: Plugin = {
|
||||
const plugin: Plugin<Hooks> = {
|
||||
hooks: {
|
||||
beforeWorkspacePacking,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user