"""Runway static site Module options."""
from __future__ import annotations
from pathlib import Path
from typing import Any, Dict, List, Optional, cast
from pydantic import Extra, root_validator
from ....config.models.base import ConfigProperty
[docs]class RunwayStaticSitePreBuildStepDataModel(ConfigProperty):
"""Model for Runway static site Module pre_build_steps option item.
Attributes:
command: The command to run.
cwd: The working directory for the subprocess running the command.
If not provided, the current working directory is used.
"""
command: str
cwd: Path = Path.cwd()
[docs] class Config(ConfigProperty.Config):
"""Model configuration."""
extra = Extra.forbid
title = "Runway static site Module pre_build_steps option item."
[docs]class RunwayStaticSiteSourceHashingDirectoryDataModel(ConfigProperty):
"""Model for Runway static site Module source_hashing.directory option item.
Attributes:
exclusions: List of gitignore formatted globs to ignore when calculating
the hash.
path: Path to files to include in the hash.
"""
exclusions: List[str] = []
path: Path
[docs] class Config(ConfigProperty.Config):
"""Model configuration."""
extra = Extra.forbid
title = "Runway static site Module source_hashing.directories option item."
[docs]class RunwayStaticSiteSourceHashingDataModel(ConfigProperty):
"""Model for Runway static site Module source_hashing option.
Attributes:
directories: Explicitly provide the directories to use when calculating
the hash. If not provided, will default to the root of the module.
enabled: Enable source hashing. If not enabled, build and upload will
occur on every deploy.
parameter: SSM parameter where the hash of each build is stored.
"""
directories: List[RunwayStaticSiteSourceHashingDirectoryDataModel] = [
RunwayStaticSiteSourceHashingDirectoryDataModel(path="./") # type: ignore
]
enabled: bool = True
parameter: Optional[str] = None
[docs] class Config(ConfigProperty.Config):
"""Model configuration."""
extra = Extra.forbid
title = "Runway static site Module source_hashing option."
[docs]class RunwayStaticSiteModuleOptionsDataModel(ConfigProperty):
"""Model for Runway static site Module options.
Attributes:
build_output: Directory where build output is placed. Defaults to current
working directory.
build_steps: List of commands to run to build the static site.
extra_files: List of files that should be uploaded to S3 after the build.
Used to dynamically create or select file.
pre_build_steps: Commands to be run prior to the build process.
source_hashing: Overrides for source hash calculation and tracking.
"""
build_output: str = "./"
build_steps: List[str] = []
extra_files: List[RunwayStaticSiteExtraFileDataModel] = []
pre_build_steps: List[RunwayStaticSitePreBuildStepDataModel] = []
source_hashing: RunwayStaticSiteSourceHashingDataModel = (
RunwayStaticSiteSourceHashingDataModel()
)
[docs] class Config(ConfigProperty.Config):
"""Model configuration."""
extra = Extra.ignore
title = "Runway static site Module options."