Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add NextjsOverrides #181

Merged
merged 20 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions .github/workflows/build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .projen/files.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 131 additions & 2 deletions .projenrc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ProjenStruct, Struct } from '@mrgrain/jsii-struct-builder';
import { BuildOptions } from 'esbuild';
import { awscdk } from 'projen';
import { JsonPatch, awscdk } from 'projen';
import { TypeScriptCompilerOptions, UpgradeDependenciesSchedule } from 'projen/lib/javascript';
import {} from 'projen/lib/github';

const commonBundlingOptions = {
bundle: true,
Expand Down Expand Up @@ -41,7 +43,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
eslintOptions: {
prettier: true,
dirs: ['src'],
ignorePatterns: ['examples/', 'e2e-tests/'],
ignorePatterns: ['examples/', 'e2e-tests/', 'optional-cdk-props/'],
},
projenrcTs: true,
tsconfig: { compilerOptions: { ...commonTscOptions } },
Expand All @@ -54,6 +56,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
devDeps: [
'@aws-crypto/sha256-js',
'@aws-sdk/client-s3',
'@mrgrain/jsii-struct-builder',
'@smithy/signature-v4',
'@types/adm-zip',
'@types/aws-lambda',
Expand All @@ -74,6 +77,132 @@ const project = new awscdk.AwsCdkConstructLibrary({
project.bundler.addBundle('./src/lambdas/nextjs-bucket-deployment.ts', commonBundlingOptions);
project.bundler.addBundle('./src/lambdas/sign-fn-url.ts', commonBundlingOptions);

const buildWorkflow = project.tryFindObjectFile('.github/workflows/build.yml');
// https://github.com/mrgrain/jsii-struct-builder/issues/174#issuecomment-1850496788
buildWorkflow?.patch(JsonPatch.replace('/jobs/build/steps/4/run', 'npx projen compile && npx projen build'));

const getFilePath = (fileName: string) => 'src/optional-cdk-props/' + fileName + '.ts';
new ProjenStruct(project, { name: 'OptionalFunctionProps', filePath: getFilePath('OptionalFunctionProps') })
.mixin(Struct.fromFqn('aws-cdk-lib.aws_lambda.FunctionProps'))
.allOptional();
new ProjenStruct(project, { name: 'OptionalCustomResourceProps', filePath: getFilePath('OptionalCustomResourceProps') })
.mixin(Struct.fromFqn('aws-cdk-lib.CustomResourceProps'))
.allOptional();
new ProjenStruct(project, { name: 'OptionalS3OriginProps', filePath: getFilePath('OptionalS3OriginProps') })
.mixin(Struct.fromFqn('aws-cdk-lib.aws_cloudfront_origins.S3OriginProps'))
.allOptional();
new ProjenStruct(project, { name: 'OptionalEdgeFunctionProps', filePath: getFilePath('OptionalEdgeFunctionProps') })
.mixin(Struct.fromFqn('aws-cdk-lib.aws_cloudfront.experimental.EdgeFunctionProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalCloudFrontFunctionProps',
filePath: getFilePath('OptionalCloudFrontFunctionProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_cloudfront.FunctionProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalDistributionProps',
filePath: getFilePath('OptionalDistributionProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_cloudfront.DistributionProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalHostedZoneProviderProps',
filePath: getFilePath('OptionalHostedZoneProviderProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_route53.HostedZoneProviderProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalCertificateProps',
filePath: getFilePath('OptionalCertificateProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_certificatemanager.CertificateProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalARecordProps',
filePath: getFilePath('OptionalARecordProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_route53.ARecordProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalAaaaRecordProps',
filePath: getFilePath('OptionalAaaaRecordProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_route53.AaaaRecordProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalTablePropsV2',
filePath: getFilePath('OptionalTablePropsV2'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_dynamodb.TablePropsV2'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalProviderProps',
filePath: getFilePath('OptionalProviderProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.custom_resources.ProviderProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalAssetProps',
filePath: getFilePath('OptionalAssetProps'),
})
.mixin(Struct.fromFqn('aws-cdk-lib.aws_s3_assets.AssetProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsBucketDeploymentProps',
filePath: getFilePath('OptionalNextjsBucketDeploymentProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsBucketDeploymentProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsBuildProps',
filePath: getFilePath('OptionalNextjsBuildProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsBuildProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsStaticAssetsProps',
filePath: getFilePath('OptionalNextjsStaticAssetsProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsStaticAssetsProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsServerProps',
filePath: getFilePath('OptionalNextjsServerProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsServerProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsImageProps',
filePath: getFilePath('OptionalNextjsImageProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsImageProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsRevalidationProps',
filePath: getFilePath('OptionalNextjsRevalidationProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsRevalidationProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsDomainProps',
filePath: getFilePath('OptionalNextjsDomainProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsDomainProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsDistributionProps',
filePath: getFilePath('OptionalNextjsDistributionProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsDistributionProps'))
.allOptional();
new ProjenStruct(project, {
name: 'OptionalNextjsInvalidationProps',
filePath: getFilePath('OptionalNextjsInvalidationProps'),
})
.mixin(Struct.fromFqn('cdk-nextjs-standalone.NextjsInvalidationProps'))
.allOptional();

// const e2eTestsWorkflow = project.github?.addWorkflow('e2e-tests');
// e2eTestsWorkflow?.on({ pullRequest: { branches: ['main'] } });
// e2eTestsWorkflow?.addJob('run-e2e-tests', {
Expand Down
Loading