1 | import { Construct } from 'constructs';
|
2 | import { AssetOptions, FileAssetPackaging } from './assets';
|
3 | import { FingerprintOptions } from './fs';
|
4 | import { Stack } from './stack';
|
5 | import { Construct as CoreConstruct } from './construct-compat';
|
6 |
|
7 |
|
8 |
|
9 | export interface AssetStagingProps extends FingerprintOptions, AssetOptions {
|
10 | |
11 |
|
12 |
|
13 | readonly sourcePath: string;
|
14 | }
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export declare class AssetStaging extends CoreConstruct {
|
34 | |
35 |
|
36 |
|
37 | static readonly BUNDLING_INPUT_DIR = "/asset-input";
|
38 | |
39 |
|
40 |
|
41 | static readonly BUNDLING_OUTPUT_DIR = "/asset-output";
|
42 | |
43 |
|
44 |
|
45 | static clearAssetHashCache(): void;
|
46 | |
47 |
|
48 |
|
49 |
|
50 | private static assetCache;
|
51 | |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | readonly stagedPath: string;
|
65 | |
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | readonly absoluteStagedPath: string;
|
77 | |
78 |
|
79 |
|
80 | readonly sourcePath: string;
|
81 | |
82 |
|
83 |
|
84 | readonly assetHash: string;
|
85 | |
86 |
|
87 |
|
88 | readonly packaging: FileAssetPackaging;
|
89 | |
90 |
|
91 |
|
92 | readonly isArchive: boolean;
|
93 | private readonly fingerprintOptions;
|
94 | private readonly hashType;
|
95 | private readonly assetOutdir;
|
96 | |
97 |
|
98 |
|
99 |
|
100 |
|
101 | private customSourceFingerprint?;
|
102 | private readonly cacheKey;
|
103 | private readonly sourceStats;
|
104 | constructor(scope: Construct, id: string, props: AssetStagingProps);
|
105 | /**
|
106 | * A cryptographic hash of the asset.
|
107 | *
|
108 | * @deprecated see `assetHash`.
|
109 | */
|
110 | get sourceHash(): string;
|
111 | /**
|
112 | * Return the path to the staged asset, relative to the Cloud Assembly (manifest) directory of the given stack
|
113 | *
|
114 | * Only returns a relative path if the asset was staged, returns an absolute path if
|
115 | * it was not staged.
|
116 | *
|
117 | * A bundled asset might end up in the outDir and still not count as
|
118 | * "staged"; if asset staging is disabled we're technically expected to
|
119 | * reference source directories, but we don't have a source directory for the
|
120 | * bundled outputs (as the bundle output is written to a temporary
|
121 | * directory). Nevertheless, we will still return an absolute path.
|
122 | *
|
123 | * A non-obvious directory layout may look like this:
|
124 | *
|
125 | * ```
|
126 | * CLOUD ASSEMBLY ROOT
|
127 | * +-- asset.12345abcdef/
|
128 | * +-- assembly-Stage
|
129 | * +-- MyStack.template.json
|
130 | * +-- MyStack.assets.json <- will contain { "path": "../asset.12345abcdef" }
|
131 | * ```
|
132 | */
|
133 | relativeStagedPath(stack: Stack): string;
|
134 | /**
|
135 | * Stage the source to the target by copying
|
136 | *
|
137 | * Optionally skip if staging is disabled, in which case we pretend we did something but we don't really.
|
138 | */
|
139 | private stageByCopying;
|
140 | /**
|
141 | * Stage the source to the target by bundling
|
142 | *
|
143 | * Optionally skip, in which case we pretend we did something but we don't really.
|
144 | */
|
145 | private stageByBundling;
|
146 | /**
|
147 | * Whether staging has been disabled
|
148 | */
|
149 | private get stagingDisabled();
|
150 | /**
|
151 | * Copies or moves the files from sourcePath to targetPath.
|
152 | *
|
153 | * Moving implies the source directory is temporary and can be trashed.
|
154 | *
|
155 | * Will not do anything if source and target are the same.
|
156 | */
|
157 | private stageAsset;
|
158 | /**
|
159 | * Determine the directory where we're going to write the bundling output
|
160 | *
|
161 | * This is the target directory where we're going to write the staged output
|
162 | * files if we can (if the hash is fully known), or a temporary directory
|
163 | * otherwise.
|
164 | */
|
165 | private determineBundleDir;
|
166 | /**
|
167 | * Bundles an asset to the given directory
|
168 | *
|
169 | * If the given directory already exists, assume that everything's already
|
170 | * in order and don't do anything.
|
171 | *
|
172 | * @param options Bundling options
|
173 | * @param bundleDir Where to create the bundle directory
|
174 | * @returns The fully resolved bundle output directory.
|
175 | */
|
176 | private bundle;
|
177 | private calculateHash;
|
178 | }
|
179 |
|
\ | No newline at end of file |