-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from bhoudu/develop
Upgrade deps
- Loading branch information
Showing
12 changed files
with
2,833 additions
and
1,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ test-folder | |
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# AWS | ||
.aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,24 @@ | ||
module.exports = { | ||
roots: [ | ||
"<rootDir>/src" | ||
], | ||
roots: ['<rootDir>/src'], | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest" | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testRegex: "(//.*|(\\.|/)(test|spec|steps))\\.tsx?$", | ||
moduleFileExtensions: [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json", | ||
"node" | ||
], | ||
modulePaths: [ | ||
'<rootDir>/lib' | ||
], | ||
testRegex: '(//.*|(\\.|/)(test|spec|steps))\\.tsx?$', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
modulePaths: ['<rootDir>/lib'], | ||
collectCoverage: true, | ||
coverageDirectory: 'reports', | ||
coverageReporters: [ | ||
'lcov', | ||
], | ||
coverageReporters: ['lcov'], | ||
reporters: [ | ||
"default", | ||
"./node_modules/jest-sonarcloud-reporter", | ||
'default', | ||
'./node_modules/jest-sonarcloud-reporter', | ||
[ | ||
"./node_modules/jest-html-reporter", | ||
'./node_modules/jest-html-reporter', | ||
{ | ||
"pageTitle": "Test Report", | ||
"includeFailureMsg": true, | ||
"includeConsoleLog": true | ||
} | ||
] | ||
] | ||
pageTitle: 'Test Report', | ||
includeFailureMsg: true, | ||
includeConsoleLog: true, | ||
}, | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import fs from 'fs'; | ||
|
||
export interface ZambdaFile { | ||
source: string; | ||
destination?: string; | ||
} | ||
|
||
export type ZambdaFolder = string | ZambdaFile; | ||
|
||
export interface ZambdaZip { | ||
name: string; | ||
folders: ZambdaFolder[]; | ||
files: ZambdaFile[]; | ||
} | ||
|
||
export interface S3Destination { | ||
path: string; | ||
prefix: string; | ||
} | ||
|
||
export interface ZambdaS3 { | ||
bucketName: string; | ||
destination?: string; | ||
} | ||
|
||
export interface ZambdaConfig { | ||
workDir: string; | ||
zip: ZambdaZip; | ||
s3?: ZambdaS3; | ||
} | ||
|
||
/** | ||
* Reads zambda config file from file system and return parsed config object | ||
* | ||
* @param configFilePath to read conf from on file system | ||
*/ | ||
export function parseZambdaConfig(configFilePath: string): ZambdaConfig { | ||
const configJson: string = fs.readFileSync(configFilePath, { | ||
encoding: 'UTF-8', | ||
}); | ||
if (!configJson) { | ||
throw new Error('JSON file: ' + configFilePath + ' cannot be read!'); | ||
} | ||
// Parse configuration | ||
return JSON.parse(configJson) as ZambdaConfig; | ||
} | ||
|
||
/** | ||
* Returns workPath ending with trailing '/' | ||
* | ||
* @param config for zambda | ||
*/ | ||
export function getWorkPath(config: ZambdaConfig): string { | ||
return config.workDir.endsWith('/') ? config.workDir : config.workDir + '/'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Upload } from '@aws-sdk/lib-storage'; | ||
import { S3, Tag } from '@aws-sdk/client-s3'; | ||
import { PutObjectCommandInput } from '@aws-sdk/client-s3/dist-types/commands/PutObjectCommand'; | ||
import { PutObjectRequest } from '@aws-sdk/client-s3/dist-types/models/models_0'; | ||
|
||
/** | ||
* Push zambda generated zip to S3 bucket | ||
* | ||
* @param s3 client to use | ||
* @param bucket to push zip in | ||
* @param key in S3 bucket | ||
* @param body zip file | ||
* @param tags to put along file in S3 | ||
* @param queueSize to use with multiple part upload client | ||
* @param partSize to use with multiple part upload client | ||
*/ | ||
export async function pushS3( | ||
s3: S3, | ||
bucket: string, | ||
key: string, | ||
body: PutObjectRequest['Body'] | string | Uint8Array | Buffer, | ||
tags: Tag[] = [], | ||
queueSize = 2, | ||
partSize = 1, | ||
): Promise<boolean> { | ||
try { | ||
const params: PutObjectCommandInput = { | ||
Bucket: bucket, | ||
Key: key, | ||
Body: body, | ||
}; | ||
const parallelUploads3 = new Upload({ | ||
client: s3, | ||
tags: [...tags], // optional tags | ||
queueSize, // optional concurrency configuration | ||
partSize, // optional size of each part in MB | ||
leavePartsOnError: false, // optional manually handle dropped parts | ||
params, | ||
}); | ||
parallelUploads3.on('httpUploadProgress', (progress) => { | ||
console.log(progress); | ||
}); | ||
return parallelUploads3.done().then(() => true); | ||
} catch (e) { | ||
console.log(e); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.