cli-node: add get and keys methods to Lockfile class
There are a few of these classes floating around the codebase - my hope by adding these methods here is that we can start unifying around this shared implementation. Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli-node': patch
|
||||
---
|
||||
|
||||
Add `get` and `keys` methods to `Lockfile` class
|
||||
@@ -98,7 +98,9 @@ export function isMonoRepo(): Promise<boolean>;
|
||||
export class Lockfile {
|
||||
createSimplifiedDependencyGraph(): Map<string, Set<string>>;
|
||||
diff(otherLockfile: Lockfile): LockfileDiff;
|
||||
get(name: string): LockfileQueryEntry[] | undefined;
|
||||
getDependencyTreeHash(startName: string): string;
|
||||
keys(): IterableIterator<string>;
|
||||
static load(path: string): Promise<Lockfile>;
|
||||
static parse(content: string): Lockfile;
|
||||
}
|
||||
@@ -116,6 +118,13 @@ export type LockfileDiffEntry = {
|
||||
range: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type LockfileQueryEntry = {
|
||||
range: string;
|
||||
version: string;
|
||||
dataKey: string;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const packageFeatureType: readonly [
|
||||
'@backstage/BackendFeature',
|
||||
|
||||
@@ -32,8 +32,12 @@ type LockfileData = {
|
||||
};
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
type LockfileQueryEntry = {
|
||||
/**
|
||||
* A single entry in a {@link Lockfile}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type LockfileQueryEntry = {
|
||||
range: string;
|
||||
version: string;
|
||||
dataKey: string;
|
||||
@@ -134,6 +138,16 @@ export class Lockfile {
|
||||
private readonly data: LockfileData,
|
||||
) {}
|
||||
|
||||
/** Returns the name of all packages available in the lockfile */
|
||||
get(name: string): LockfileQueryEntry[] | undefined {
|
||||
return this.packages.get(name);
|
||||
}
|
||||
|
||||
/** Get the entries for a single package in the lockfile */
|
||||
keys(): IterableIterator<string> {
|
||||
return this.packages.keys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simplified dependency graph from the lockfile data, where each
|
||||
* key is a package, and the value is a set of all packages that it depends on
|
||||
|
||||
@@ -27,4 +27,5 @@ export {
|
||||
Lockfile,
|
||||
type LockfileDiff,
|
||||
type LockfileDiffEntry,
|
||||
type LockfileQueryEntry,
|
||||
} from './Lockfile';
|
||||
|
||||
Reference in New Issue
Block a user