This repository was archived by the owner on Jan 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
packages/serverless-components/nextjs-component Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -982,4 +982,33 @@ describe("Custom inputs", () => {
982
982
} ) ;
983
983
} ) ;
984
984
} ) ;
985
+
986
+ describe ( "Skip deployment after build" , ( ) => {
987
+ const fixturePath = path . join ( __dirname , "./fixtures/simple-app" ) ;
988
+ let tmpCwd : string ;
989
+
990
+ beforeEach ( async ( ) => {
991
+ tmpCwd = process . cwd ( ) ;
992
+ process . chdir ( fixturePath ) ;
993
+
994
+ mockServerlessComponentDependencies ( { expectedDomain : undefined } ) ;
995
+ } ) ;
996
+
997
+ afterEach ( ( ) => {
998
+ process . chdir ( tmpCwd ) ;
999
+ return cleanupFixtureDirectory ( fixturePath ) ;
1000
+ } ) ;
1001
+
1002
+ it ( "builds but skips deployment" , async ( ) => {
1003
+ const result = await createNextComponent ( ) . default ( {
1004
+ deploy : false
1005
+ } ) ;
1006
+
1007
+ expect ( result ) . toEqual ( {
1008
+ appUrl : "SKIPPED_DEPLOY" ,
1009
+ bucketName : "SKIPPED_DEPLOY" ,
1010
+ distributionId : "SKIPPED_DEPLOY"
1011
+ } ) ;
1012
+ } ) ;
1013
+ } ) ;
985
1014
} ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ import type {
22
22
LambdaInput
23
23
} from "../types" ;
24
24
25
+ // Message when deployment is explicitly skipped
26
+ const SKIPPED_DEPLOY = "SKIPPED_DEPLOY" ;
27
+
25
28
export type DeploymentResult = {
26
29
appUrl : string ;
27
30
bucketName : string ;
@@ -206,6 +209,16 @@ class NextjsComponent extends Component {
206
209
async deploy (
207
210
inputs : ServerlessComponentInputs = { }
208
211
) : Promise < DeploymentResult > {
212
+ // Skip deployment if user explicitly set deploy input to false.
213
+ // Useful when they just want the build outputs to deploy themselves.
214
+ if ( inputs . deploy === false ) {
215
+ return {
216
+ appUrl : SKIPPED_DEPLOY ,
217
+ bucketName : SKIPPED_DEPLOY ,
218
+ distributionId : SKIPPED_DEPLOY
219
+ } ;
220
+ }
221
+
209
222
const nextConfigPath = inputs . nextConfigDir
210
223
? resolve ( inputs . nextConfigDir )
211
224
: process . cwd ( ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export type ServerlessComponentInputs = {
21
21
cloudfront ?: CloudfrontOptions ;
22
22
minifyHandlers ?: boolean ;
23
23
uploadStaticAssetsFromBuild ?: boolean ;
24
+ deploy ?: boolean ;
24
25
} ;
25
26
26
27
type CloudfrontOptions = Record < string , any > ;
You can’t perform that action at this time.
0 commit comments