refactor: create a package for hook types (#6380)

This commit is contained in:
Zoltan Kochan
2023-04-12 11:47:28 +03:00
committed by GitHub
parent 0ab1e52504
commit ece5a1aeb9
14 changed files with 122 additions and 15 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/hooks.types": major
---
Initial release.

View File

@@ -33,9 +33,9 @@
"@pnpm/pnpmfile": "workspace:*"
},
"dependencies": {
"@pnpm/core": "workspace:*",
"@pnpm/core-loggers": "workspace:*",
"@pnpm/error": "workspace:*",
"@pnpm/hooks.types": "workspace:*",
"@pnpm/lockfile-types": "workspace:*",
"@pnpm/store-controller-types": "workspace:*",
"@pnpm/types": "workspace:*",

View File

@@ -1,5 +1,5 @@
import path from 'path'
import type { PreResolutionHook, PreResolutionHookContext, PreResolutionHookLogger } from '@pnpm/core'
import type { PreResolutionHook, PreResolutionHookContext, PreResolutionHookLogger } from '@pnpm/hooks.types'
import { hookLogger } from '@pnpm/core-loggers'
import pathAbsolute from 'path-absolute'
import type { Lockfile } from '@pnpm/lockfile-types'

View File

@@ -25,10 +25,10 @@
"path": "../../packages/types"
},
{
"path": "../../pkg-manager/core"
"path": "../../store/store-controller-types"
},
{
"path": "../../store/store-controller-types"
"path": "../types"
}
],
"composite": true

15
hooks/types/README.md Normal file
View File

@@ -0,0 +1,15 @@
# @pnpm/hooks.types
> Types for hooks
[![npm version](https://img.shields.io/npm/v/@pnpm/hooks.types.svg)](https://www.npmjs.com/package/@pnpm/hooks.types)
## Installation
```sh
pnpm add @pnpm/hooks.types
```
## License
MIT

41
hooks/types/package.json Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "@pnpm/hooks.types",
"version": "0.0.0",
"description": "Types for hooks",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"!*.map"
],
"engines": {
"node": ">=16.14"
},
"scripts": {
"test": "pnpm run compile",
"prepublishOnly": "pnpm run compile",
"compile": "tsc --build && pnpm run lint --fix",
"lint": "eslint \"src/**/*.ts\""
},
"repository": "https://github.com/pnpm/pnpm/blob/main/hooks/types",
"keywords": [
"pnpm8",
"pnpm"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/hooks/types#readme",
"devDependencies": {
"@pnpm/hooks.types": "workspace:*"
},
"dependencies": {
"@pnpm/lockfile-types": "workspace:*",
"@pnpm/types": "workspace:*"
},
"funding": "https://opencollective.com/pnpm",
"exports": {
".": "./lib/index.js"
}
}

View File

@@ -1,4 +1,4 @@
import type { Lockfile } from '@pnpm/lockfile-file'
import type { Lockfile } from '@pnpm/lockfile-types'
import type { Registries } from '@pnpm/types'
export interface PreResolutionHookContext {

20
hooks/types/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"extends": "@pnpm/tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../__typings__/**/*.d.ts"
],
"references": [
{
"path": "../../lockfile/lockfile-types"
},
{
"path": "../../packages/types"
}
],
"composite": true
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"test/**/*.ts",
"../../__typings__/**/*.d.ts"
]
}

View File

@@ -28,6 +28,7 @@
"@pnpm/headless": "workspace:*",
"@pnpm/hoist": "workspace:*",
"@pnpm/hooks.read-package-hook": "workspace:*",
"@pnpm/hooks.types": "workspace:*",
"@pnpm/lifecycle": "workspace:*",
"@pnpm/link-bins": "workspace:*",
"@pnpm/lockfile-file": "workspace:*",

View File

@@ -8,7 +8,6 @@ export type {
} from '@pnpm/types'
export type { HoistingLimits } from '@pnpm/headless'
export * from './api'
export * from './install/hooks'
export { type ProjectOptions, UnexpectedStoreError, UnexpectedVirtualStoreDirError } from '@pnpm/get-context'
export type { InstallOptions } from './install/extendInstallOptions'

View File

@@ -17,7 +17,7 @@ import {
} from '@pnpm/types'
import { pnpmPkgJson } from '../pnpmPkgJson'
import { type ReporterFunction } from '../types'
import { type PreResolutionHookContext } from './hooks'
import { type PreResolutionHookContext } from '@pnpm/hooks.types'
export interface StrictInstallOptions {
autoInstallPeers: boolean

View File

@@ -42,6 +42,9 @@
{
"path": "../../hooks/read-package-hook"
},
{
"path": "../../hooks/types"
},
{
"path": "../../lockfile/filter-lockfile"
},

31
pnpm-lock.yaml generated
View File

@@ -1582,15 +1582,15 @@ importers:
hooks/pnpmfile:
dependencies:
'@pnpm/core':
specifier: workspace:*
version: link:../../pkg-manager/core
'@pnpm/core-loggers':
specifier: workspace:*
version: link:../../packages/core-loggers
'@pnpm/error':
specifier: workspace:*
version: link:../../packages/error
'@pnpm/hooks.types':
specifier: workspace:*
version: link:../types
'@pnpm/lockfile-types':
specifier: workspace:*
version: link:../../lockfile/lockfile-types
@@ -1663,6 +1663,19 @@ importers:
specifier: 4.0.0-rc.42
version: 4.0.0-rc.42(typanion@3.12.1)
hooks/types:
dependencies:
'@pnpm/lockfile-types':
specifier: workspace:*
version: link:../../lockfile/lockfile-types
'@pnpm/types':
specifier: workspace:*
version: link:../../packages/types
devDependencies:
'@pnpm/hooks.types':
specifier: workspace:*
version: 'link:'
lockfile/audit:
dependencies:
'@pnpm/error':
@@ -2668,6 +2681,9 @@ importers:
'@pnpm/hooks.read-package-hook':
specifier: workspace:*
version: link:../../hooks/read-package-hook
'@pnpm/hooks.types':
specifier: workspace:*
version: link:../../hooks/types
'@pnpm/lifecycle':
specifier: workspace:*
version: link:../../exec/lifecycle
@@ -8787,7 +8803,7 @@ packages:
dependencies:
'@types/http-cache-semantics': 4.0.1
'@types/keyv': 3.1.4
'@types/node': 18.15.11
'@types/node': 14.18.42
'@types/responselike': 1.0.0
/@types/concat-stream@2.0.0:
@@ -8815,7 +8831,7 @@ packages:
resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==}
dependencies:
'@types/minimatch': 5.1.2
'@types/node': 18.15.11
'@types/node': 14.18.42
dev: true
/@types/graceful-fs@4.1.6:
@@ -8889,7 +8905,7 @@ packages:
/@types/keyv@3.1.4:
resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==}
dependencies:
'@types/node': 18.15.11
'@types/node': 14.18.42
/@types/lodash@4.14.181:
resolution: {integrity: sha512-n3tyKthHJbkiWhDZs3DkhkCzt2MexYHXlX0td5iMplyfwketaOeKboEVBqzceH7juqvEg3q5oUoBFxSLu7zFag==}
@@ -8932,7 +8948,6 @@ packages:
/@types/node@14.18.42:
resolution: {integrity: sha512-xefu+RBie4xWlK8hwAzGh3npDz/4VhF6icY/shU+zv/1fNn+ZVG7T7CRwe9LId9sAYRPxI+59QBPuKL3WpyGRg==}
dev: true
/@types/node@18.15.11:
resolution: {integrity: sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==}
@@ -8969,7 +8984,7 @@ packages:
/@types/responselike@1.0.0:
resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==}
dependencies:
'@types/node': 18.15.11
'@types/node': 14.18.42
/@types/retry@0.12.2:
resolution: {integrity: sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==}