1- import path from 'node:path'
2- import { tmpdir } from 'node:os'
31import { mkdir , mkdtemp , rm , writeFile } from 'node:fs/promises'
4- import { simpleGit } from 'simple-git '
5- import { SSMClient , GetParameterCommand } from '@aws-sdk/client-ssm '
2+ import { tmpdir } from 'node:os '
3+ import path from 'node:path '
64import { S3Client } from '@aws-sdk/client-s3'
5+ import { GetParameterCommand , SSMClient } from '@aws-sdk/client-ssm'
76import { Octokit } from 'octokit'
7+ import { simpleGit } from 'simple-git'
88
99import envs from '../../lib/envs'
10- import type { Summary } from '../../lib/types'
1110import { logger , middify } from '../../lib/lambda-common'
11+ import type { Summary } from '../../lib/types'
1212import { getS3JSON } from '../../lib/utils'
1313import { createPullRequestDescription } from './pr-description'
1414
@@ -21,10 +21,12 @@ const ssmClient = new SSMClient({})
2121const s3Client = new S3Client ( { } )
2222
2323// A personal access token is used to clone and push from/to GitHub
24- const gitHubUserCredentialsPromise = ssmClient . send ( new GetParameterCommand ( {
25- Name : GIT_HUB_CREDENTIALS_SSM_PARAMETER ,
26- WithDecryption : true
27- } ) )
24+ const gitHubUserCredentialsPromise = ssmClient . send (
25+ new GetParameterCommand ( {
26+ Name : GIT_HUB_CREDENTIALS_SSM_PARAMETER ,
27+ WithDecryption : true ,
28+ } ) ,
29+ )
2830
2931interface PullRequestEvent {
3032 transcriptKey : string
@@ -59,7 +61,9 @@ export const handleEvent = middify(async (event: PullRequestEvent) => {
5961 }
6062 const [ username , password ] = gitHubUserCredentials . split ( ':' )
6163 if ( username === undefined || password === undefined || username === '' || password === '' ) {
62- throw new Error ( `${ GIT_HUB_CREDENTIALS_SSM_PARAMETER } SSM Parameter should be in the format <Username>:<GitHubPersonalAccessToken>` )
64+ throw new Error (
65+ `${ GIT_HUB_CREDENTIALS_SSM_PARAMETER } SSM Parameter should be in the format <Username>:<GitHubPersonalAccessToken>` ,
66+ )
6367 }
6468
6569 const gitUrl = new URL ( GIT_REPO_URL )
@@ -97,9 +101,14 @@ export const handleEvent = middify(async (event: PullRequestEvent) => {
97101 const base = TARGET_BRANCH === undefined ? 'main' : TARGET_BRANCH
98102 const repoPath = gitUrl . pathname
99103 const [ , owner ] = repoPath . split ( '/' )
100- const response = await octokit . request (
101- `POST /repos/${ owner } /${ repoName } /pulls` , { owner, title, body, head, base, repo : repoName }
102- )
104+ const response = await octokit . request ( `POST /repos/${ owner } /${ repoName } /pulls` , {
105+ owner,
106+ title,
107+ body,
108+ head,
109+ base,
110+ repo : repoName ,
111+ } )
103112 const prUrl = response . data . html_url
104113 console . log ( 'Created PR' , { prUrl } )
105114 return { prUrl }
0 commit comments