-
Notifications
You must be signed in to change notification settings - Fork 4
/
project-config.ts
86 lines (74 loc) · 2.4 KB
/
project-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { join } from "path"
import { Region } from "../aws/common/model.js"
import { TakomoError } from "../utils/errors.js"
import { expandFilePath, FilePath } from "../utils/files.js"
export type DeploymentTargetRepositoryType = string
export interface DeploymentTargetRepositoryConfig {
readonly type: DeploymentTargetRepositoryType
readonly [key: string]: unknown
}
export interface TakomoProjectDeploymentTargetsConfig {
readonly repository?: ReadonlyArray<DeploymentTargetRepositoryConfig>
}
/**
* Feature flags.
*/
export interface Features {
/**
* Enable deployment targets undeploy command
*/
readonly deploymentTargetsUndeploy: boolean
}
export const defaultFeatures = (): Features => ({
deploymentTargetsUndeploy: true,
})
export const defaultEsbuild = (projectDir: FilePath): EsbuildConfig => ({
enabled: true,
entryPoint: expandFilePath(projectDir, "takomo.ts"),
outFile: expandFilePath(projectDir, join(".takomo", "out", "takomo.mjs")),
})
/**
* Takomo project configuration.
*/
export interface TakomoProjectConfig {
readonly requiredVersion?: string
readonly deploymentTargets?: TakomoProjectDeploymentTargetsConfig
readonly regions: ReadonlyArray<Region>
}
export interface ExternalResolverConfig {
readonly name?: string
readonly package: string
}
export interface ExternalHandlebarsHelperConfig {
readonly name?: string
readonly package: string
}
export interface EsbuildConfig {
readonly enabled: boolean
readonly outFile: FilePath
readonly entryPoint: FilePath
}
export type TemplateEngineType = "handlebars" | "ejs"
export interface InternalTakomoProjectConfig extends TakomoProjectConfig {
readonly resolvers: ReadonlyArray<ExternalResolverConfig>
readonly helpers: ReadonlyArray<ExternalHandlebarsHelperConfig>
readonly features: Features
readonly varFiles: ReadonlyArray<FilePath>
readonly helpersDir: ReadonlyArray<FilePath>
readonly partialsDir: ReadonlyArray<FilePath>
readonly schemasDir: ReadonlyArray<FilePath>
readonly esbuild: EsbuildConfig
readonly templateEngine: TemplateEngineType
}
export class FeatureDisabledError extends TakomoError {
constructor(featureName: keyof Features) {
super(
`Can't execute operation because feature '${featureName}' is not enabled`,
{
instructions: [
`To enable this operation, set features.${featureName} = true in the project configuration`,
],
},
)
}
}