Skip to content

Commit ec964c7

Browse files
fix: Updated script with logger
1 parent a262359 commit ec964c7

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

scripts/change-log-helper.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ChangeLogHelper {
2121
}
2222

2323
async getAllReleaseVersionsFromGivenDate(date) {
24-
this.logger.debug(`Started detecting the versions from the date: ${date}`);
24+
this.logger.info(`Started detecting the versions from the date: ${date}`);
2525
const versions = [];
2626
const readLine = await this.getReadLiner(this.oaiChangelogFilename);
2727
for await (const line of readLine) {
@@ -36,38 +36,38 @@ class ChangeLogHelper {
3636
}
3737
}
3838
}
39-
this.logger.debug(`Detected Versions: ${versions}`);
39+
this.logger.info(`Detected Versions: ${versions}`);
4040
return versions;
4141
}
4242

4343
async getLatestChangelogGeneratedDate() {
44-
this.logger.debug('Started detecting the latest date in cli core changelog');
44+
this.logger.info('Started detecting the latest date in cli core changelog');
4545
let latestDate;
4646
const readLine = await this.getReadLiner(this.cliCoreChangelogFilename);
4747
for await (const line of readLine) {
4848
latestDate = this.dateRegex.exec(line);
4949
if (latestDate) {
5050
latestDate = latestDate[0];
51-
this.logger.debug(`Detected the latest Date: ${latestDate}`);
51+
this.logger.info(`Detected the latest Date: ${latestDate}`);
5252
break;
5353
}
5454
}
5555
return latestDate;
5656
}
5757

5858
async getChangesAfterGivenDate(date) {
59-
this.logger.debug(`Started getting the changelog from given date: ${date}`);
59+
this.logger.info(`Started getting the changelog from given date: ${date}`);
6060
let readLines = false;
6161
let fileData = '';
6262
const readLine = await this.getReadLiner(this.oaiChangelogFilename);
6363
for await (const line of readLine) {
6464
const currentDate = this.dateRegex.exec(line);
6565
if (currentDate) {
6666
if (currentDate[0] > date) {
67-
this.logger.debug('Reading the lines');
67+
this.logger.info('Reading the lines');
6868
readLines = true;
6969
} else {
70-
this.logger.debug(`Changes from OpenAPI specs: ${fileData}`);
70+
this.logger.info(`Changes from OpenAPI specs: ${fileData}`);
7171
break;
7272
}
7373
} else if (readLines) {
@@ -78,13 +78,13 @@ class ChangeLogHelper {
7878
}
7979

8080
async getAndAppendChangesToChangelog() {
81-
this.logger.debug('Started getAndAppendChangesToChangelog');
81+
this.logger.info('Started getAndAppendChangesToChangelog');
8282
const latestDate = await this.getLatestChangelogGeneratedDate(); // changes.md
8383
if (latestDate) {
8484
const changeLog = await this.getChangesAfterGivenDate(latestDate); // oai_changes.md
8585
if (changeLog) {
8686
try {
87-
this.logger.debug('Updating the CHANGES.md');
87+
this.logger.info('Updating the CHANGES.md');
8888
const data = fs.readFileSync(this.cliCoreChangelogFilename);
8989
const fd = fs.openSync(this.cliCoreChangelogFilename, 'w+');
9090
const insert = Buffer.from(changeLog);
@@ -93,6 +93,7 @@ class ChangeLogHelper {
9393
fs.close(fd, (err) => {
9494
if (err) throw err;
9595
});
96+
fs.writeFileSync('changeLog.md', changeLog);
9697
} catch (error) {
9798
this.logger.error(`Error while updating the changelog: ${error}`);
9899
}

scripts/get-version-type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const getVersionType = async () => {
1616
return -1;
1717
};
1818
(async () => {
19-
console.log(await getVersionType());
19+
return getVersionType();
2020
})();

scripts/updateApiDefinitions.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
echo "Copying api-definitions"
33
cp -R ~/oai_definitions/json/. src/services/twilio-api/
44
echo "Running update changelog script"
5-
changeLog=$(node scripts/update-api-definitions.js)
5+
node update-api-definitions.js
6+
changeLog=$(cat changeLog.md)
7+
rm -rf changeLog.md
68
if [ "$changeLog" != '' ]; then
79
changeLog="${changeLog//'%'/'%25'}"
810
changeLog="${changeLog//$'\n'/'%0A'}"
911
changeLog="${changeLog//$'\r'/'%0D'}"
1012
fi
1113
echo "Changelog: $changeLog"
12-
versionType=$(node scripts/get-version-type.js)
14+
versionType=$(node scripts/get-version-type.js | tail -n -1)
1315
echo "Version type: $versionType"
1416
rm -rf OAI_CHANGES.md
1517
echo "Git configurations"

0 commit comments

Comments
 (0)