Skip to content

AssetStaging

Stages a file or directory from a location on the file system into a staging directory.

This is controlled by the context key 'aliyun:ros:disable-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.

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.

Initializers

import { AssetStaging } from '@alicloud/ros-cdk-core'
new AssetStaging(scope: Construct, id: string, props: AssetStagingProps)
Name Type Description
scope Construct No description.
id string No description.
props AssetStagingProps No description.

scopeRequired


idRequired

  • Type: string

propsRequired


Methods

Name Description
toString Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
relativeStagedPath Return the path to the staged asset, relative to the Cloud Assembly (manifest) directory of the given stack.

toString

public toString(): string

Returns a string representation of this construct.

synthesize

public synthesize(session: ISynthesisSession): void

Allows this construct to emit artifacts into the cloud assembly during synthesis.

This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.

sessionRequired

The synthesis session.


relativeStagedPath

public relativeStagedPath(stack: Stack): string

Return the path to the staged asset, relative to the Cloud Assembly (manifest) directory of the given stack.

Only returns a relative path if the asset was staged, returns an absolute path if it was not staged.

A bundled asset might end up in the outDir and still not count as "staged"; if asset staging is disabled we're technically expected to reference source directories, but we don't have a source directory for the bundled outputs (as the bundle output is written to a temporary directory). Nevertheless, we will still return an absolute path.

A non-obvious directory layout may look like this:

   CLOUD ASSEMBLY ROOT
     +-- asset.12345abcdef/
     +-- assembly-Stage
           +-- MyStack.template.json
           +-- MyStack.assets.json <- will contain { "path": "../asset.12345abcdef" }

stackRequired


Static Functions

Name Description
isConstruct Return whether the given object is a Construct.
clearAssetHashCache Clears the asset hash cache.

isConstruct

import { AssetStaging } from '@alicloud/ros-cdk-core'
AssetStaging.isConstruct(x: any)

Return whether the given object is a Construct.

xRequired

  • Type: any

clearAssetHashCache

import { AssetStaging } from '@alicloud/ros-cdk-core'
AssetStaging.clearAssetHashCache()

Clears the asset hash cache.

Properties

Name Type Description
node ConstructNode The construct tree node associated with this construct.
absoluteStagedPath string Absolute path to the asset data.
assetHash string A cryptographic hash of the asset.
isArchive boolean Whether this asset is an archive (zip or jar).
packaging FileAssetPackaging How this asset should be packaged.
sourcePath string The absolute path of the asset as it was referenced by the user.

nodeRequired

public readonly node: ConstructNode;

The construct tree node associated with this construct.


absoluteStagedPathRequired

public readonly absoluteStagedPath: string;
  • Type: string

Absolute path to the asset data.

If asset staging is disabled, this will just be the source path or a temporary directory used for bundling.

If asset staging is enabled it will be the staged path.

IMPORTANT: If you are going to call addFileAsset(), use relativeStagedPath() instead.


assetHashRequired

public readonly assetHash: string;
  • Type: string

A cryptographic hash of the asset.


isArchiveRequired

public readonly isArchive: boolean;
  • Type: boolean

Whether this asset is an archive (zip or jar).


packagingRequired

public readonly packaging: FileAssetPackaging;

How this asset should be packaged.


sourcePathRequired

public readonly sourcePath: string;
  • Type: string

The absolute path of the asset as it was referenced by the user.


Constants

Name Type Description
BUNDLING_INPUT_DIR string The directory inside the bundling container into which the asset sources will be mounted.
BUNDLING_OUTPUT_DIR string The directory inside the bundling container into which the bundled output should be written.

BUNDLING_INPUT_DIRRequired

public readonly BUNDLING_INPUT_DIR: string;
  • Type: string

The directory inside the bundling container into which the asset sources will be mounted.


BUNDLING_OUTPUT_DIRRequired

public readonly BUNDLING_OUTPUT_DIR: string;
  • Type: string

The directory inside the bundling container into which the bundled output should be written.