UNPKG

@stacksjs/cloud

Version:

The Stacks cloud/serverless integration & implementation.

60 lines (54 loc) 1.93 kB
import type { Construct } from 'constructs'; import type { NestedCloudProps } from '../types'; export declare interface DeploymentStackProps extends NestedCloudProps { publicBucket: s3.Bucket docsBucket?: s3.Bucket privateBucket: s3.Bucket mainDistribution: cloudfront.Distribution docsDistribution?: cloudfront.Distribution } export declare class DeploymentStack { privateSource: string docsSource: string publicSource: string constructor(scope: Construct, props: DeploymentStackProps) { this.privateSource = '../../private' this.docsSource = '../docs/dist/' this.publicSource = config.app.docMode === true ? this.docsSource : '../views/web/dist/' const mainBucket = config.app.docMode === true ? props.docsBucket : props.publicBucket new s3deploy.BucketDeployment(scope, 'Website', { sources: [ s3deploy.Source.asset(this.publicSource, { assetHash: websiteSourceHash(), assetHashType: AssetHashType.CUSTOM, }), ], destinationBucket: mainBucket as s3.Bucket, distribution: props.mainDistribution, }) if (this.shouldDeployDocs()) { new s3deploy.BucketDeployment(scope, 'Docs', { sources: [ s3deploy.Source.asset(this.docsSource, { assetHash: docsSourceHash(), assetHashType: AssetHashType.CUSTOM, }), ], destinationBucket: props.docsBucket as s3.Bucket, distribution: props.docsDistribution, }) } if (hasFiles(this.privateSource)) { new s3deploy.BucketDeployment(scope, 'PrivateFiles', { sources: [s3deploy.Source.asset(this.privateSource)], destinationBucket: props.privateBucket, }) } else { console.error(`The path ${this.privateSource} does not have any files`) } } shouldDeployDocs(): boolean { return hasFiles(p.projectPath('docs')) && !config.app.docMode } }