Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 5adaf2b

Browse files
authored
feat(nextjs-component): add deploy input which can be set to false to skip deployment (#691)
1 parent 000377d commit 5adaf2b

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

packages/serverless-components/nextjs-component/__tests__/custom-inputs.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,4 +982,33 @@ describe("Custom inputs", () => {
982982
});
983983
});
984984
});
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+
});
9851014
});

packages/serverless-components/nextjs-component/src/component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import type {
2222
LambdaInput
2323
} from "../types";
2424

25+
// Message when deployment is explicitly skipped
26+
const SKIPPED_DEPLOY = "SKIPPED_DEPLOY";
27+
2528
export type DeploymentResult = {
2629
appUrl: string;
2730
bucketName: string;
@@ -206,6 +209,16 @@ class NextjsComponent extends Component {
206209
async deploy(
207210
inputs: ServerlessComponentInputs = {}
208211
): 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+
209222
const nextConfigPath = inputs.nextConfigDir
210223
? resolve(inputs.nextConfigDir)
211224
: process.cwd();

packages/serverless-components/nextjs-component/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type ServerlessComponentInputs = {
2121
cloudfront?: CloudfrontOptions;
2222
minifyHandlers?: boolean;
2323
uploadStaticAssetsFromBuild?: boolean;
24+
deploy?: boolean;
2425
};
2526

2627
type CloudfrontOptions = Record<string, any>;

0 commit comments

Comments
 (0)