File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { paramCase } from 'param-case' ;
2
+ import { IStaticWebsitePreviewNamingToken } from './tokens' ;
2
3
3
4
export interface IStaticWebsitePreviewNamingStrategy {
4
5
/**
@@ -15,6 +16,13 @@ export class StaticWebsitePreviewNamingStrategy implements IStaticWebsitePreview
15
16
return new StaticWebsitePreviewNamingStrategy ( name ) ;
16
17
}
17
18
19
+ /**
20
+ * Crafts a name from an array of token values.
21
+ */
22
+ static fromTokens ( ...tokens : IStaticWebsitePreviewNamingToken [ ] ) : IStaticWebsitePreviewNamingStrategy {
23
+ return new StaticWebsitePreviewNamingStrategy ( tokens . map ( ( { token } ) => token ) . join ( '-' ) ) ;
24
+ }
25
+
18
26
/**
19
27
* Sub-domain that will be used to host the preview.
20
28
*/
Original file line number Diff line number Diff line change
1
+ import { Aws } from 'aws-cdk-lib' ;
2
+
3
+ export interface IStaticWebsitePreviewNamingToken {
4
+ token : string ;
5
+ }
6
+
7
+ export class StaticWebsitePreviewNamingToken implements IStaticWebsitePreviewNamingToken {
8
+ static fromString ( val : string ) : IStaticWebsitePreviewNamingToken {
9
+ return new StaticWebsitePreviewNamingToken ( val ) ;
10
+ }
11
+
12
+ static get AWS_ACCOUNT_ID ( ) : IStaticWebsitePreviewNamingToken {
13
+ return new StaticWebsitePreviewNamingToken ( Aws . ACCOUNT_ID ) ;
14
+ }
15
+
16
+ static get AWS_REGION ( ) : IStaticWebsitePreviewNamingToken {
17
+ return new StaticWebsitePreviewNamingToken ( Aws . REGION ) ;
18
+ }
19
+
20
+ static get AWS_STACK_NAME ( ) : IStaticWebsitePreviewNamingToken {
21
+ return new StaticWebsitePreviewNamingToken ( Aws . STACK_NAME ) ;
22
+ }
23
+
24
+ constructor ( public readonly token : string ) { }
25
+ }
You can’t perform that action at this time.
0 commit comments