UNPKG

@almamedia-open-source/cdk-project-target

Version:

![CDK Version](https://img.shields.io/badge/CDK-v2-informational "CDK v2") ![Stability](https://img.shields.io/badge/Stability-Experimental-yellow "Stability: Experimental")

158 lines (157 loc) 4.73 kB
import { Construct } from 'constructs'; import { EnvironmentLabel, EnvironmentCategory } from '../configurations/environments'; /** * @experimental */ export declare class EnvironmentContext { /** * (experimental) Get Environment Name. * * @param scope Construct. * @returns Environment Name (as given via `--context environment`) * @experimental * @example * * 'mock1' * 'mock2' * 'mock3' * 'development' * 'feature/foo-bar' * 'feature/ABC-123/new-stuff' * 'test' * 'staging' * 'qa1' * 'qa2' * 'qa3' * 'preproduction' * 'production' */ static getName(scope: Construct): string; /** * (experimental) Get Environment URL/DNS Compatible Name. * * @param scope Construct. * @returns Environment URL/DNS Compatible Name (as given via `--context environment` but `param-cased`) * @experimental * @example * * 'mock1' * 'mock2' * 'mock3' * 'development' * 'feature-foo-bar' * 'feature-abc-123-new-stuff' * 'test' * 'staging' * 'qa1' * 'qa2' * 'qa3' * 'preproduction' * 'production' */ static getUrlName(scope: Construct): string; /** * (experimental) Get Environment Label. * * Labels are useful since Environment Name can be complex, * such as `feature/foo-bar` or `qa3`, * but we need to be able to “label” all `feature/*` and `qaN` environments * as either `feature` or `qa`. * * @param scope Construct. * @returns Environment Label * @experimental * @example * * 'mock' * 'development' * 'feature' * 'test' * 'staging' * 'qa' * 'preproduction' * 'production' */ static getLabel(scope: Construct): EnvironmentLabel; /** * (experimental) Get Environment Category. * * Categories are useful grouping to make distinction between `stable` * environments (`staging` & `production`) from `feature` or `verification` * environments (such as `test` or `preproduction`). * * @param scope Construct. * @returns Environment Category * @experimental * @example * * 'mock' * 'development' * 'feature' * 'verification' * 'stable' */ static getCategory(scope: Construct): EnvironmentCategory; /** * (experimental) Check if Environment is part of `mock` category. * * @param scope Construct. * @returns boolean indicating does Environment belong to `mock` category * @experimental */ static isMock(scope: Construct): boolean; /** * (experimental) Check if Environment is part of `development` category. * * Returns true for `development`, otherwise `false`. * * @param scope Construct. * @returns boolean indicating does Environment belong to `development` category * @experimental */ static isDevelopment(scope: Construct): boolean; /** * (experimental) Check if Environment is part of `feature` category. * * Returns `true` for environments with name beginning with `feature/`-prefix, otherwise `false`. * * @param scope Construct. * @returns boolean indicating does Environment belong to `feature` category * @experimental */ static isFeature(scope: Construct): boolean; /** * (experimental) Check if Environment is part of `verification` category. * * Returns `true` for `test` & `preproduction`, otherwise `false`. * * @param scope Construct. * @returns boolean indicating does Environment belong to `verification` category * @experimental */ static isVerification(scope: Construct): boolean; /** * (experimental) Check if Environment is part of `stable` category. * * Returns `true` for `staging` & `production`, otherwise `false`. * * @param scope Construct. * @returns boolean indicating does Environment belong to `stable` category * @experimental */ static isStable(scope: Construct): boolean; /** * (experimental) Get Feature Info. * * If environment belongs to `feature` category, * this will return a string describing the feature (sting after `feature/`-prefix). * * If environment is not a feature environment, will return an empty string. * * @param scope Construct. * @returns string indicating the feature this environment relates to, if not feature environment returns an empty string * @experimental */ static getFeatureInfo(scope: Construct): string; private static isEnvironmentCategoryMatch; }