forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support shrinkwrap-deps.json and cleanup
- Loading branch information
Showing
7 changed files
with
282 additions
and
221 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { PackageName, FileSystem } from '@rushstack/node-core-library'; | |
import { RushConstants } from '../../logic/RushConstants'; | ||
import { DependencySpecifier } from '../DependencySpecifier'; | ||
import { IPolicyValidatorOptions } from '../policy/PolicyValidator'; | ||
import { PackageManagerOptionsConfigurationBase, RushConfiguration } from '../../api/RushConfiguration'; | ||
import { PackageManagerOptionsConfigurationBase } from '../../api/RushConfiguration'; | ||
|
||
/** | ||
* This class is a parser for both npm's npm-shrinkwrap.json and pnpm's pnpm-lock.yaml file formats. | ||
|
@@ -95,20 +95,6 @@ export abstract class BaseShrinkwrapFile { | |
return this._checkDependencyVersion(dependencySpecifier, shrinkwrapDependency); | ||
} | ||
|
||
public tryEnsureCompatibleWorkspaceDependency( | ||
dependencySpecifier: DependencySpecifier, | ||
projectName: string, | ||
rushConfiguration: RushConfiguration | ||
): boolean { | ||
const shrinkwrapDependency: DependencySpecifier | undefined = | ||
this.tryEnsureWorkspaceDependencyVersion(dependencySpecifier, projectName, rushConfiguration); | ||
if (!shrinkwrapDependency) { | ||
return false; | ||
} | ||
|
||
return this._checkDependencyVersion(dependencySpecifier, shrinkwrapDependency); | ||
} | ||
|
||
/** | ||
* Returns the list of temp projects defined in this file. | ||
* Example: [ '@rush-temp/project1', '@rush-temp/project2' ] | ||
|
@@ -117,29 +103,61 @@ export abstract class BaseShrinkwrapFile { | |
*/ | ||
public abstract getTempProjectNames(): ReadonlyArray<string>; | ||
|
||
/** @virtual */ | ||
protected abstract tryEnsureDependencyVersion(dependencySpecifier: DependencySpecifier, | ||
tempProjectName: string): DependencySpecifier | undefined; | ||
|
||
/** @virtual */ | ||
protected abstract getTopLevelDependencyVersion(dependencyName: string): DependencySpecifier | undefined; | ||
|
||
/** | ||
* Returns true if the specified workspace in the shrinkwrap file includes a package that would | ||
* satisfy the specified SemVer version range. | ||
* | ||
* Consider this example: | ||
* | ||
* - project-a\ | ||
* - [email protected] | ||
* - [email protected] | ||
* - [email protected] | ||
* | ||
* In this example, hasCompatibleWorkspaceDependency("lib-b", ">= 1.1.0", "workspace-key-for-project-a") | ||
* would fail because it finds [email protected] which does not satisfy the pattern ">= 1.1.0". | ||
* | ||
* @virtual | ||
*/ | ||
public hasCompatibleWorkspaceDependency(dependencySpecifier: DependencySpecifier, workspaceKey: string): boolean { | ||
const shrinkwrapDependency: DependencySpecifier | undefined = this.getWorkspaceDependencyVersion( | ||
dependencySpecifier, | ||
workspaceKey | ||
); | ||
return shrinkwrapDependency | ||
? this._checkDependencyVersion(dependencySpecifier, shrinkwrapDependency) | ||
: false; | ||
} | ||
|
||
/** | ||
* Returns the list of paths to Rush projects relative to the | ||
* install root. | ||
* Returns the list of keys to workspace projects specified in the shrinkwrap. | ||
* Example: [ '../../apps/project1', '../../apps/project2' ] | ||
* | ||
* @virtual | ||
*/ | ||
public abstract getWorkspacePaths(): ReadonlyArray<string>; | ||
public abstract getWorkspaceKeys(): ReadonlyArray<string>; | ||
|
||
/** @virtual */ | ||
protected abstract tryEnsureDependencyVersion(dependencySpecifier: DependencySpecifier, | ||
tempProjectName: string): DependencySpecifier | undefined; | ||
/** | ||
* Returns the key to the project in the workspace specified by the shrinkwrap. | ||
* Example: '../../apps/project1' | ||
* | ||
* @virtual | ||
*/ | ||
public abstract getWorkspaceKeyByPath(workspaceRoot: string, projectFolder: string): string | ||
|
||
/** @virtual */ | ||
protected abstract tryEnsureWorkspaceDependencyVersion( | ||
protected abstract getWorkspaceDependencyVersion( | ||
dependencySpecifier: DependencySpecifier, | ||
projectName: string, | ||
rushConfiguration: RushConfiguration | ||
workspaceKey: string | ||
): DependencySpecifier | undefined; | ||
|
||
/** @virtual */ | ||
protected abstract getTopLevelDependencyVersion(dependencyName: string): DependencySpecifier | undefined; | ||
|
||
/** @virtual */ | ||
protected abstract serialize(): string; | ||
|
||
|
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.