Skip to content

Commit 12e3fab

Browse files
committed
chore: add logging for debugging purpose
1 parent 46d613e commit 12e3fab

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/aws.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import type { ReadStream } from 'fs'
23

34
import type aws from 'aws-sdk'
@@ -30,6 +31,7 @@ export class AWS {
3031
public readonly awsS3: InstanceType<typeof aws.S3>
3132

3233
constructor(accessKey: string, secretAccessKey: string) {
34+
console.log('Initializing AWS S3...')
3335
this.awsS3 = new S3({
3436
computeChecksums: true,
3537
credentials: new Credentials(accessKey, secretAccessKey),
@@ -38,6 +40,8 @@ export class AWS {
3840
}
3941

4042
public async deleteFile(bucket: string, pathToDelete: string) {
43+
console.log('Deleting file from bucket:', bucket, 'path:', pathToDelete)
44+
4145
return new Promise((_resolve, reject) => {
4246
const deleteParam = {
4347
Bucket: bucket,
@@ -53,6 +57,8 @@ export class AWS {
5357
}
5458

5559
public async getExistingFiles(bucket: string, prefix?: string) {
60+
console.log('Getting existing files from bucket:', bucket, 'with prefix:', prefix)
61+
5662
async function existingFilesKeys(
5763
s3: S3,
5864
param: ListObjectsV2Request,
@@ -96,6 +102,7 @@ export class AWS {
96102
}
97103

98104
public async uploadFile(bucket: string, key: string, body: ReadStream, objectMimeType: string, objectACL?: ObjectCannedACL) {
105+
console.log('Uploading file to bucket:', bucket, 'with key:', key, 'and mimeType:', objectMimeType)
99106
const uploadParams: PutObjectRequest = {
100107
ACL: objectACL,
101108
Body: body,

src/publish.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
13
import fs from 'fs'
24
import * as path from 'path'
35

@@ -15,10 +17,11 @@ import type {
1517

1618
export async function publish(config: PluginConfig, context: Context) {
1719
const awsConfig = AWS.loadConfig(config, context) as WithoutNullableKeys<AWSConfig>
18-
20+
console.log('Publish step start')
1921
const s3 = new AWS(awsConfig.awsAccessKey, awsConfig.awsSecretAccessKey)
2022

2123
const filePaths = await globby(config.directoryPath)
24+
console.log('Found file paths:', filePaths)
2225

2326
let s3Bucket: string | undefined
2427

@@ -36,6 +39,8 @@ export async function publish(config: PluginConfig, context: Context) {
3639
}
3740
)
3841

42+
console.log('S3 bucket:', s3BucketWithResolvedVariables)
43+
3944
const [
4045
bucketName,
4146
...bucketPrefixes
@@ -46,6 +51,7 @@ export async function publish(config: PluginConfig, context: Context) {
4651
})
4752

4853
if (!bucketName) {
54+
console.log('Error: Missing s3 bucket configuration.')
4955
throw new Error('Missing s3 bucket configuration. ' +
5056
'Please check your plugin configuration and add a valid ' +
5157
's3 bucket name or s3 bucket configuration for one or more git branches.')
@@ -97,6 +103,8 @@ export async function publish(config: PluginConfig, context: Context) {
97103

98104
await Promise.allSettled(publishPromises)
99105

106+
console.log('S3 publishing successful, URL:', `https://${bucketName}.s3.amazonaws.com/${bucketPrefix}`)
107+
100108
return {
101109
name: 'S3 release',
102110
url: `https://${bucketName}.s3.amazonaws.com/${bucketPrefix}`,

src/verifyConditions.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
13
import AggregateError from 'aggregate-error'
24
import type { Context } from 'semantic-release'
35

@@ -9,6 +11,7 @@ export function verifyConditions(config: PluginConfig, context: Context): void {
911
const errors = []
1012

1113
const awsConfig = AWS.loadConfig(config, context)
14+
console.log('Verify Conditions step start')
1215

1316
if (!awsConfig.awsAccessKey) {
1417
errors.push(getError('ENOACCESSKEYID'))
@@ -26,6 +29,8 @@ export function verifyConditions(config: PluginConfig, context: Context): void {
2629
errors.push(getError('ENODIRECTORYPATH'))
2730
}
2831

32+
console.log('Errors occurred during verification:', errors)
33+
2934
if (errors.length > 0) {
3035
throw new AggregateError(errors)
3136
}

0 commit comments

Comments
 (0)