Skip to content

Commit

Permalink
refactor: create read-package-hook package
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Sep 25, 2022
1 parent b877deb commit 0351910
Show file tree
Hide file tree
Showing 19 changed files with 164 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-socks-press.md
@@ -0,0 +1,5 @@
---
"@pnpm/hooks.read-package-hook": major
---

First release.
3 changes: 1 addition & 2 deletions packages/core/package.json
Expand Up @@ -26,6 +26,7 @@
"@pnpm/graph-sequencer": "1.0.0",
"@pnpm/headless": "workspace:*",
"@pnpm/hoist": "workspace:*",
"@pnpm/hooks.read-package-hook": "workspace:*",
"@pnpm/lifecycle": "workspace:*",
"@pnpm/link-bins": "workspace:*",
"@pnpm/lockfile-file": "workspace:*",
Expand All @@ -39,7 +40,6 @@
"@pnpm/normalize-registries": "workspace:*",
"@pnpm/npm-package-arg": "^1.0.0",
"@pnpm/package-requester": "workspace:*",
"@pnpm/parse-overrides": "workspace:*",
"@pnpm/parse-wanted-dependency": "workspace:*",
"@pnpm/prune-lockfile": "workspace:*",
"@pnpm/read-modules-dir": "workspace:*",
Expand All @@ -52,7 +52,6 @@
"@pnpm/symlink-dependency": "workspace:*",
"@pnpm/types": "workspace:*",
"@pnpm/which-version-is-pinned": "workspace:*",
"@yarnpkg/extensions": "1.2.0-rc.1",
"@zkochan/rimraf": "^2.1.2",
"dependency-path": "workspace:*",
"is-inner-link": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getPeerDependencyIssues.ts
@@ -1,7 +1,7 @@
import resolveDependencies, { getWantedDependencies } from '@pnpm/resolve-dependencies'
import { PeerDependencyIssuesByProjects } from '@pnpm/types'
import getContext, { GetContextOptions, ProjectOptions } from '@pnpm/get-context'
import { createReadPackageHook } from './install/createReadPackageHook'
import { createReadPackageHook } from '@pnpm/hooks.read-package-hook'
import { getPreferredVersionsFromLockfile } from './install/getPreferredVersions'
import { InstallOptions } from './install/extendInstallOptions'
import { DEFAULT_REGISTRIES } from '@pnpm/normalize-registries'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/install/extendInstallOptions.ts
@@ -1,6 +1,7 @@
import { WANTED_LOCKFILE } from '@pnpm/constants'
import PnpmError from '@pnpm/error'
import { HoistingLimits } from '@pnpm/headless'
import { createReadPackageHook } from '@pnpm/hooks.read-package-hook'
import { Lockfile } from '@pnpm/lockfile-file'
import { IncludedDependencies } from '@pnpm/modules-yaml'
import normalizeRegistries, { DEFAULT_REGISTRIES } from '@pnpm/normalize-registries'
Expand All @@ -15,7 +16,6 @@ import {
} from '@pnpm/types'
import pnpmPkgJson from '../pnpmPkgJson'
import { ReporterFunction } from '../types'
import { createReadPackageHook } from './createReadPackageHook'
import { PreResolutionHookContext } from './hooks'

export interface StrictInstallOptions {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/tsconfig.json
Expand Up @@ -63,6 +63,9 @@
{
"path": "../hoist"
},
{
"path": "../hooks.read-package-hook"
},
{
"path": "../lifecycle"
},
Expand Down Expand Up @@ -102,9 +105,6 @@
{
"path": "../package-store"
},
{
"path": "../parse-overrides"
},
{
"path": "../parse-wanted-dependency"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/hooks.read-package-hook/README.md
@@ -0,0 +1,13 @@
# @pnpm/hooks.read-package-hook

> Creates the default package reader hook used by pnpm
## Installation

```sh
pnpm add @pnpm/hooks.read-package-hook
```

## License

MIT
3 changes: 3 additions & 0 deletions packages/hooks.read-package-hook/jest.config.js
@@ -0,0 +1,3 @@
const config = require('../../jest.config.js');

module.exports = Object.assign({}, config, {});
51 changes: 51 additions & 0 deletions packages/hooks.read-package-hook/package.json
@@ -0,0 +1,51 @@
{
"name": "@pnpm/hooks.read-package-hook",
"version": "0.0.0",
"description": "Creates the default package reader hook used by pnpm",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"!*.map"
],
"scripts": {
"lint": "eslint src/**/*.ts test/**/*.ts",
"_test": "jest",
"test": "pnpm run compile && pnpm run _test",
"prepublishOnly": "pnpm run compile",
"compile": "tsc --build && pnpm run lint --fix"
},
"repository": "https://github.com/pnpm/pnpm/blob/main/packages/hooks.read-package-hook",
"keywords": [
"pnpm7"
],
"engines": {
"node": ">=14.6"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/hooks.read-package-hook#readme",
"dependencies": {
"@pnpm/matcher": "workspace:*",
"@pnpm/parse-overrides": "workspace:*",
"@pnpm/parse-wanted-dependency": "workspace:*",
"@pnpm/types": "workspace:*",
"@yarnpkg/extensions": "1.2.0-rc.1",
"normalize-path": "^3.0.0",
"ramda": "npm:@pnpm/ramda@0.28.1",
"semver": "^7.3.7"
},
"devDependencies": {
"@pnpm/hooks.read-package-hook": "workspace:*",
"@types/normalize-path": "^3.0.0",
"@types/ramda": "0.28.15",
"@types/semver": "7.3.10",
"@yarnpkg/core": "4.0.0-rc.14"
},
"funding": "https://opencollective.com/pnpm",
"exports": {
".": "./lib/index.js"
}
}
1 change: 1 addition & 0 deletions packages/hooks.read-package-hook/src/index.ts
@@ -0,0 +1 @@
export { createReadPackageHook } from './createReadPackageHook'
@@ -1,4 +1,4 @@
import createPackageExtender from '../../lib/install/createPackageExtender'
import createPackageExtender from '../lib/createPackageExtender'

const packageExtender = createPackageExtender({
foo: {
Expand Down
@@ -1,4 +1,4 @@
import createPeerDependencyPatcher from '../../lib/install/createPeerDependencyPatcher'
import createPeerDependencyPatcher from '../lib/createPeerDependencyPatcher'

test('createPeerDependencyPatcher() ignores missing', () => {
const patcher = createPeerDependencyPatcher({
Expand Down
@@ -1,5 +1,5 @@
import path from 'path'
import createVersionsOverrider from '../../lib/install/createVersionsOverrider'
import createVersionsOverrider from '../lib/createVersionsOverrider'

test('createVersionsOverrider() matches subranges', () => {
const overrider = createVersionsOverrider({
Expand Down
25 changes: 25 additions & 0 deletions packages/hooks.read-package-hook/tsconfig.json
@@ -0,0 +1,25 @@
{
"extends": "@pnpm/tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../typings/**/*.d.ts"
],
"references": [
{
"path": "../matcher"
},
{
"path": "../parse-overrides"
},
{
"path": "../parse-wanted-dependency"
},
{
"path": "../types"
}
]
}
8 changes: 8 additions & 0 deletions packages/hooks.read-package-hook/tsconfig.lint.json
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"test/**/*.ts",
"../../typings/**/*.d.ts"
]
}
58 changes: 49 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0351910

Please sign in to comment.