-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1210 from tnc1997/tnc1997/pnpm-version-3
[rush] Add support for PNPM version 3.x
- Loading branch information
Showing
24 changed files
with
419 additions
and
73 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import { RushConstants } from '../../logic/RushConstants'; | ||
import { PackageManager } from './PackageManager'; | ||
|
||
/** | ||
* Support for interacting with the NPM package manager. | ||
*/ | ||
export class NpmPackageManager extends PackageManager { | ||
/** @internal */ | ||
public constructor(version: string) { | ||
super(version, 'npm'); | ||
|
||
this._shrinkwrapFilename = RushConstants.npmShrinkwrapFilename; | ||
} | ||
} |
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,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
/** | ||
* This represents the available Package Manager tools as a string | ||
* @public | ||
*/ | ||
export type PackageManagerName = 'pnpm' | 'npm' | 'yarn'; | ||
|
||
/** | ||
* An abstraction for controlling the supported package managers: PNPM, NPM, and Yarn. | ||
* @beta | ||
*/ | ||
export abstract class PackageManager { | ||
/** | ||
* The package manager. | ||
*/ | ||
public readonly packageManager: PackageManagerName; | ||
|
||
/** | ||
* The SemVer version of the package manager. | ||
*/ | ||
public readonly version: string; | ||
|
||
protected _shrinkwrapFilename: string; | ||
|
||
/** @internal */ | ||
protected constructor(version: string, packageManager: PackageManagerName) { | ||
this.version = version; | ||
this.packageManager = packageManager; | ||
} | ||
|
||
/** | ||
* The filename of the shrinkwrap file that is used by the package manager. | ||
* | ||
* @remarks | ||
* Example: `npm-shrinkwrap.json` or `pnpm-lock.yaml` | ||
*/ | ||
public get shrinkwrapFilename(): string { | ||
return this._shrinkwrapFilename; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
apps/rush-lib/src/api/packageManager/PnpmPackageManager.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import * as semver from 'semver'; | ||
import { RushConstants } from '../../logic/RushConstants'; | ||
import { PackageManager } from './PackageManager'; | ||
|
||
/** | ||
* Support for interacting with the PNPM package manager. | ||
*/ | ||
export class PnpmPackageManager extends PackageManager { | ||
/** | ||
* PNPM only. True if `--resolution-strategy` is supported. | ||
*/ | ||
public readonly supportsResolutionStrategy: boolean; | ||
|
||
/** @internal */ | ||
public constructor(version: string) { | ||
super(version, 'pnpm'); | ||
|
||
const parsedVersion: semver.SemVer = new semver.SemVer(version); | ||
|
||
this.supportsResolutionStrategy = false; | ||
|
||
if (parsedVersion.major >= 3) { | ||
this._shrinkwrapFilename = RushConstants.pnpmV3ShrinkwrapFilename; | ||
|
||
if (parsedVersion.minor >= 1) { | ||
// Introduced in version 3.1.0-0 | ||
this.supportsResolutionStrategy = true; | ||
} | ||
} else { | ||
this._shrinkwrapFilename = RushConstants.pnpmV1ShrinkwrapFilename; | ||
} | ||
} | ||
} |
Oops, something went wrong.