UNPKG

@aws-cdk/core

Version:

AWS Cloud Development Kit Core Library

101 lines (100 loc) 3.63 kB
import { Construct } from 'constructs'; import { AssetOptions } from './assets'; import { FingerprintOptions } from './fs'; import { Construct as CoreConstruct } from './construct-compat'; /** * Initialization properties for `AssetStaging`. */ export interface AssetStagingProps extends FingerprintOptions, AssetOptions { /** * The source file or directory to copy from. */ readonly sourcePath: string; } /** * Stages a file or directory from a location on the file system into a staging directory. * * This is controlled by the context key 'aws:cdk:asset-staging' and enabled * by the CLI by default in order to ensure that when the CDK app exists, all * assets are available for deployment. Otherwise, if an app references assets * in temporary locations, those will not be available when it exists (see * https://github.com/aws/aws-cdk/issues/1716). * * The `stagedPath` property is a stringified token that represents the location * of the file or directory after staging. It will be resolved only during the * "prepare" stage and may be either the original path or the staged path * depending on the context setting. * * The file/directory are staged based on their content hash (fingerprint). This * means that only if content was changed, copy will happen. */ export declare class AssetStaging extends CoreConstruct { /** * (experimental) The directory inside the bundling container into which the asset sources will be mounted. * * @experimental */ static readonly BUNDLING_INPUT_DIR = "/asset-input"; /** * (experimental) The directory inside the bundling container into which the bundled output should be written. * * @experimental */ static readonly BUNDLING_OUTPUT_DIR = "/asset-output"; /** * Clears the asset hash cache. */ static clearAssetHashCache(): void; /** * Cache of asset hashes based on asset configuration to avoid repeated file * system and bundling operations. */ private static assetHashCache; /** * Get asset hash from cache or calculate it in case of cache miss. */ private static getOrCalcAssetHash; /** * The path to the asset (stringinfied token). * * If asset staging is disabled, this will just be the original path. * If asset staging is enabled it will be the staged path. */ readonly stagedPath: string; /** * The path of the asset as it was referenced by the user. */ readonly sourcePath: string; /** * (deprecated) A cryptographic hash of the asset. * * @deprecated see `assetHash`. */ readonly sourceHash: string; /** * A cryptographic hash of the asset. */ readonly assetHash: string; private readonly fingerprintOptions; private readonly relativePath?; private bundleDir?; private readonly cacheKey; /** * */ constructor(scope: Construct, id: string, props: AssetStagingProps); private stageAsset; /** * Bundles an asset and provides the emitted asset's directory in return. * * @param options Bundling options * @param outdir Parent directory to create the bundle output directory in * @param sourceHash The asset source hash if known in advance. If this field * is provided, the bundler may opt to skip bundling, providing any already- * emitted bundle. If this field is not provided, the bundler uses an * intermediate directory in outdir. * @returns The fully resolved bundle output directory. */ private bundle; private calculateHash; }