@@ -101,21 +101,56 @@ export interface SimpleSynthActionProps extends SimpleSynthOptions {
101
101
/**
102
102
* The install command
103
103
*
104
+ * If not provided by the build image or another dependency
105
+ * management tool, at least install the CDK CLI here using
106
+ * `npm install -g aws-cdk`.
107
+ *
104
108
* @default - No install required
109
+ * @deprecated Use `installCommands` instead
105
110
*/
106
111
readonly installCommand ?: string ;
107
112
108
113
/**
109
114
* The build command
110
115
*
111
- * By default, we assume NPM projects are either written in JavaScript or are
112
- * using `ts-node`, so don't need a build command.
113
- *
114
- * Otherwise, put the build command here, for example `npm run build`.
116
+ * If your programming language requires a compilation step, put the
117
+ * compilation command here.
115
118
*
116
119
* @default - No build required
120
+ * @deprecated Use `buildCommands` instead
117
121
*/
118
122
readonly buildCommand ?: string ;
123
+
124
+ /**
125
+ * Install commands
126
+ *
127
+ * If not provided by the build image or another dependency
128
+ * management tool, at least install the CDK CLI here using
129
+ * `npm install -g aws-cdk`.
130
+ *
131
+ * @default - No install required
132
+ */
133
+ readonly installCommands ?: string [ ] ;
134
+
135
+ /**
136
+ * The build commands
137
+ *
138
+ * If your programming language requires a compilation step, put the
139
+ * compilation command here.
140
+ *
141
+ * @default - No build required
142
+ */
143
+ readonly buildCommands ?: string [ ] ;
144
+
145
+ /**
146
+ * Test commands
147
+ *
148
+ * These commands are run after the build commands but before the
149
+ * synth command.
150
+ *
151
+ * @default - No test commands
152
+ */
153
+ readonly testCommands ?: string [ ] ;
119
154
}
120
155
121
156
/**
@@ -190,6 +225,14 @@ export class SimpleSynthAction implements codepipeline.IAction {
190
225
outputs : [ props . cloudAssemblyArtifact , ...( props . additionalArtifacts ?? [ ] ) . map ( a => a . artifact ) ] ,
191
226
} ;
192
227
228
+ if ( this . props . installCommand && this . props . installCommands ) {
229
+ throw new Error ( 'Pass either \'installCommand\' or \'installCommands\', but not both' ) ;
230
+ }
231
+
232
+ if ( this . props . buildCommand && this . props . buildCommands ) {
233
+ throw new Error ( 'Pass either \'buildCommand\' or \'buildCommands\', but not both' ) ;
234
+ }
235
+
193
236
const addls = props . additionalArtifacts ?? [ ] ;
194
237
if ( Object . keys ( addls ) . length > 0 ) {
195
238
if ( ! props . cloudAssemblyArtifact . artifactName ) {
@@ -214,9 +257,10 @@ export class SimpleSynthAction implements codepipeline.IAction {
214
257
* Exists to implement IAction
215
258
*/
216
259
public bind ( scope : Construct , stage : codepipeline . IStage , options : codepipeline . ActionBindOptions ) : codepipeline . ActionConfig {
217
- const buildCommand = this . props . buildCommand ;
260
+ const buildCommands = this . props . buildCommands ?? [ this . props . buildCommand ] ;
261
+ const installCommands = this . props . installCommands ?? [ this . props . installCommand ] ;
262
+ const testCommands = this . props . testCommands ?? [ ] ;
218
263
const synthCommand = this . props . synthCommand ;
219
- const installCommand = this . props . installCommand ;
220
264
221
265
const project = new codebuild . PipelineProject ( scope , 'CdkBuildProject' , {
222
266
projectName : this . props . projectName ?? this . props . projectName ,
@@ -227,12 +271,13 @@ export class SimpleSynthAction implements codepipeline.IAction {
227
271
pre_build : {
228
272
commands : filterEmpty ( [
229
273
this . props . subdirectory ? `cd ${ this . props . subdirectory } ` : '' ,
230
- installCommand ,
274
+ ... installCommands ,
231
275
] ) ,
232
276
} ,
233
277
build : {
234
278
commands : filterEmpty ( [
235
- buildCommand ,
279
+ ...buildCommands ,
280
+ ...testCommands ,
236
281
synthCommand ,
237
282
] ) ,
238
283
} ,
0 commit comments