aws-delivlib
Version:
A fabulous library for defining continuous pipelines for building, testing and releasing code libraries.
104 lines (103 loc) • 3.87 kB
TypeScript
/// <reference types="node" />
import type { RequestOptions, IncomingMessage } from 'http';
import { Repository } from './repository';
/**
* Published package.
*/
export interface PublishedPackage {
/**
* Name of the package as stored in the package manager.
*/
readonly name: string;
/**
* Version of the package as stored in the package manager.
*/
readonly version: string;
}
/**
* Integrity class for validating a local artifact against its published counterpart.
*
* Implementations differ based on the package manager in question.
*/
export declare abstract class ArtifactIntegrity {
/**
* The file extenstion of artifacts produced for this check. (e.g 'whl')
*/
protected abstract readonly ext: string;
/**
* Download a package to the target file.
*
* @param pkg The package to download.
* @param targetFile The file path to download the package to.
*/
protected abstract download(pkg: PublishedPackage, targetFile: string): Promise<void>;
/**
* Extract the artifact into the target directory.
*
* @param artifact Path to an artifact file.
* @param targetDir The directory to extract to. It will exist by the time this method is invoked.
*/
protected abstract extract(artifact: string, targetDir: string): Promise<void>;
/**
* Parse a local artifact file name into a structured package.
*
* @param artifactName Base name of the local artifact file.
* @returns The package this artifact correlates to.
*/
protected abstract parseArtifactName(artifactName: string): PublishedPackage;
/**
* Validate a local artifact against its published counterpart.
*
* @param localArtifactDir The directory of the local artifact. Must contain exactly one file with the appropriate extenstion.
*/
validate(localArtifactDir: string): Promise<void>;
protected log(message: string): void;
private findOne;
}
/**
* Properties for `RepositoryIntegrity`.
*/
export interface RepositoryIntegrityProps {
/**
* Repository to validate.
*/
readonly repository: Repository;
/**
* The command that produces the local artifacts.
*
* @default 'npx projen release'
*/
readonly packCommand?: string;
}
/**
* Integrity class for validating the artifacts produced by this repository against their published counterparts.
*/
export declare class RepositoryIntegrity {
private readonly props;
constructor(props: RepositoryIntegrityProps);
/**
* Validate the artifacts of this repo against its published counterpart.
*/
validate(): Promise<void>;
}
/**
* NpmIntegrity is able to perform integrity checks against packages stored on npmjs.com
*/
export declare class NpmArtifactIntegrity extends ArtifactIntegrity {
protected readonly ext = "tgz";
protected download(pkg: PublishedPackage, target: string): Promise<void>;
extract(file: string, targetDir: string): Promise<void>;
protected parseArtifactName(artifactName: string): PublishedPackage;
}
/**
* PyPIIntegiry is able to perform integiry checks against packages stored on pypi.org
*/
export declare class PyPIArtifactIntegrity extends ArtifactIntegrity {
protected readonly ext = "whl";
protected download(pkg: PublishedPackage, target: string): Promise<void>;
extract(artifact: string, target: string): Promise<void>;
protected parseArtifactName(artifactName: string): PublishedPackage;
}
export declare function jsonGet(url: string, jsonPath?: string[]): Promise<any>;
export declare function download(url: string, targetFile: string): Promise<any>;
export declare function get(url: string, handler: (res: IncomingMessage, ok: (value: unknown) => void, ko: (err: Error) => void) => void, options?: RequestOptions): Promise<unknown>;