-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: linking direct dependencies (#5669)
- Loading branch information
Showing
14 changed files
with
267 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pnpm/pkg-manager.direct-dep-linker": minor | ||
--- | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,9 @@ | |
{ | ||
"path": "../client" | ||
}, | ||
{ | ||
"path": "../direct-dep-linker" | ||
}, | ||
{ | ||
"path": "../get-context" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# @pnpm/pkg-manager.direct-dep-linker | ||
|
||
> Links direct dependencies to projects | ||
## Installation | ||
|
||
``` | ||
pnpm install @pnpm/pkg-manager.direct-dep-linker | ||
``` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@pnpm/pkg-manager.direct-dep-linker", | ||
"description": "Fast installation using only pnpm-lock.yaml", | ||
"version": "0.0.0", | ||
"bugs": { | ||
"url": "https://github.com/pnpm/pnpm/issues" | ||
}, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"!*.map" | ||
], | ||
"peerDependencies": { | ||
"@pnpm/logger": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@pnpm/pkg-manager.direct-dep-linker": "workspace:*" | ||
}, | ||
"homepage": "https://github.com/pnpm/pnpm/blob/main/pkg-manager/direct-dep-linker#readme", | ||
"keywords": [ | ||
"pnpm7", | ||
"pnpm" | ||
], | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=14.6" | ||
}, | ||
"repository": "https://github.com/pnpm/pnpm/blob/main/pkg-manager/direct-dep-linker", | ||
"scripts": { | ||
"lint": "eslint src/**/*.ts", | ||
"test": "pnpm run compile", | ||
"prepublishOnly": "pnpm run compile", | ||
"compile": "tsc --build && pnpm run lint --fix" | ||
}, | ||
"dependencies": { | ||
"@pnpm/core-loggers": "workspace:*", | ||
"@pnpm/symlink-dependency": "workspace:*" | ||
}, | ||
"funding": "https://opencollective.com/pnpm", | ||
"exports": { | ||
".": "./lib/index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './linkDirectDeps' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { rootLogger } from '@pnpm/core-loggers' | ||
import { symlinkDependency, symlinkDirectRootDependency } from '@pnpm/symlink-dependency' | ||
|
||
export interface LinkedDirectDep { | ||
alias: string | ||
name: string | ||
version: string | ||
dir: string | ||
id: string | ||
dependencyType: 'prod' | 'dev' | 'optional' | ||
isExternalLink: boolean | ||
latest?: string | ||
} | ||
|
||
export interface ProjectToLink { | ||
dir: string | ||
modulesDir: string | ||
dependencies: LinkedDirectDep[] | ||
} | ||
|
||
export async function linkDirectDeps ( | ||
projects: ProjectToLink[] | ||
) { | ||
await Promise.all(projects.map(async (project) => { | ||
await Promise.all(project.dependencies.map(async (dep) => { | ||
if (dep.isExternalLink) { | ||
await symlinkDirectRootDependency(dep.dir, project.modulesDir, dep.alias, { | ||
fromDependenciesField: dep.dependencyType === 'dev' && 'devDependencies' || | ||
dep.dependencyType === 'optional' && 'optionalDependencies' || | ||
'dependencies', | ||
linkedPackage: { | ||
name: dep.name, | ||
version: dep.version, | ||
}, | ||
prefix: project.dir, | ||
}) | ||
return | ||
} | ||
if ((await symlinkDependency(dep.dir, project.modulesDir, dep.alias)).reused) { | ||
return | ||
} | ||
rootLogger.debug({ | ||
added: { | ||
dependencyType: dep.dependencyType, | ||
id: dep.id, | ||
latest: dep.latest, | ||
name: dep.alias, | ||
realName: dep.name, | ||
version: dep.version, | ||
}, | ||
prefix: project.dir, | ||
}) | ||
})) | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "@pnpm/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src" | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
"../../__typings__/**/*.d.ts" | ||
], | ||
"references": [ | ||
{ | ||
"path": "../../fs/symlink-dependency" | ||
}, | ||
{ | ||
"path": "../../packages/core-loggers" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"src/**/*.ts", | ||
"test/**/*.ts", | ||
"../../__typings__/**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.