Skip to content

Commit

Permalink
- Added publish timestamp to debug message (along with delivery confi…
Browse files Browse the repository at this point in the history
…rmation)

- Sequenced the interactive prompts for stm feed contribute
  • Loading branch information
gvensan committed Aug 12, 2024
1 parent 0466bc3 commit 2625a8d
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 75 deletions.
4 changes: 2 additions & 2 deletions src/common/publish-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export class SolaceClient extends VisualizeClient {
//ACKNOWLEDGED MESSAGE implies that the vpn has confirmed message receipt
this.session.on(solace.SessionEventCode.ACKNOWLEDGED_MESSAGE, (sessionEvent: solace.SessionEvent) => {
if (sessionEvent.correlationKey)
Logger.logSuccess("delivery of message with correlation key '" + sessionEvent.correlationKey + "' confirmed");
Logger.logSuccess(`delivery of message with correlation key '${sessionEvent.correlationKey}' confirmed [${new Date().toLocaleString()}]`);
else
Logger.logSuccess("delivery of message confirmed");
Logger.logSuccess(`delivery of message confirmed [${new Date().toLocaleString()}]`);
});

//REJECTED_MESSAGE implies that the vpn has rejected the message
Expand Down
150 changes: 77 additions & 73 deletions src/lib/feed-contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { defaultEventFeedsFile, defaultFakerRulesFile, defaultFeedAnalysisFile,
defaultFeedInfoFile, defaultFeedRulesFile, defaultFeedSchemasFile, defaultStmFeedsHome, defaultGitRepo } from '../utils/defaults';
import { chalkBoldLabel, chalkBoldVariable, chalkBoldWhite } from '../utils/chalkUtils';
import { getLocalEventFeeds } from '../utils/listfeeds';
import { prettyJSON } from '../utils/prettify';

const contribute = async (options: ManageFeedClientOptions, optionsSource: any) => {
const { Select, Confirm, Input, List } = require('enquirer');
Expand Down Expand Up @@ -32,7 +33,7 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)
Logger.info('Let us first update the feed information\n')

var info:any = loadLoadFeedInfo(feedName);
console.log('Current', info);
Logger.logMessage(`${chalkBoldWhite('Current Feed Information:')}\n` + prettyJSON(JSON.stringify(info)));

if (info.contributed) {
const pContributed = new Confirm({
Expand All @@ -56,47 +57,65 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)

// Take user input

const pFeedDesc = new Input({
message: `${chalkBoldWhite('Feed description')}\n` +
`${chalkBoldLabel('Hint')}: A brief description on the scope and purpose of the feed\n`,
initial: info.description,
validate: (value: string) => { return !!value; }
const pFeedDesc = new Input({
message: `${chalkBoldWhite('Feed description')}\n` +
`${chalkBoldLabel('Hint')}: A brief description on the scope and purpose of the feed\n`,
initial: info.description,
validate: (value: string) => { return !!value; }
});

await pFeedDesc.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.description !== answer;
info.description = answer
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});

await pFeedDesc.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.description !== answer;
info.description = answer
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});

const pFeedDomain = new Input({
message: `${chalkBoldWhite('Feed domain')}\n` +
`${chalkBoldLabel('Hint')}: A high-level business domain that the feed can be identified with\n`,
initial: info.domain,
validate: (value: string) => { return !!value; }
});

await pFeedDomain.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.domain !== answer;
info.domain = answer
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});
const pFeedDomain = new Input({
message: `${chalkBoldWhite('Feed domain')}\n` +
`${chalkBoldLabel('Hint')}: A high-level business domain that the feed can be identified with\n`,
initial: info.domain,
validate: (value: string) => { return !!value; }
});

await pFeedDomain.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.domain !== answer;
info.domain = answer
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});

const pFeedIcon = new Input({
message: `${chalkBoldWhite('Feed icon (an URL or a base64 image data)')}\n` +
`${chalkBoldLabel('Hint')}: Leave blank to use a default feed icon\n`,
initial: info.img
});

const pFeedIcon = new Input({
message: `${chalkBoldWhite('Feed icon (an URL or a base64 image data)')}\n` +
`${chalkBoldLabel('Hint')}: Leave blank to use a default feed icon\n`,
initial: info.img
const pFeedTags = new List({
name: 'tags',
message: `${chalkBoldWhite('Feed keywords (as a comma-separated values)')}\n` +
`${chalkBoldLabel('Hint')}: Keywords that the feed's scope and purpose can be identified with\n`,
initial: info.tags,
validate: (value: string) => { return !!value; }
});

await pFeedTags.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.tags !== answer.join(', ');
info.tags = answer.join(', ');
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});

await pFeedIcon.run()
await pFeedIcon.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.img !== answer;
info.img = answer ? answer : 'assets/img/defaultfeed.png'
Expand All @@ -108,7 +127,7 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)

const pFeedContributor = new Input({
message: `${chalkBoldWhite('Contributor name')}\n` +
`${chalkBoldLabel('Hint')}: Contributor name for attribution\n`,
`${chalkBoldLabel('Hint')}: Contributor name for attribution. If not specified the contribution will be attributed to Solace Community!\n`,
initial: info.contributor
});

Expand All @@ -125,7 +144,7 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)

const pGitUser = new Input({
message: `${chalkBoldWhite('GitHub handle')}\n` +
`${chalkBoldLabel('Hint')}: Optional, can be updated at the time of feed contribution\n`,
`${chalkBoldLabel('Hint')}: Contributor's GitHub handle for attribution. If not specified the contribution will be attributed to Solace Community!\n`,
initial: info.github
});

Expand All @@ -139,26 +158,27 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)
process.exit(1);
});

const pFeedTags = new List({
name: 'tags',
message: `${chalkBoldWhite('Feed keywords (as a comma-separated values)')}\n` +
`${chalkBoldLabel('Hint')}: Keywords that the feed's scope and purpose can be identified with\n`,
initial: info.tags,
validate: (value: string) => { return !!value; }
});

await pFeedTags.run()
.then((answer:any) => {
if (!infoUpdated) infoUpdated = info.tags !== answer.join(', ');
info.tags = answer.join(', ');
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
do {
const pUserEmail = new Input({
message: `${chalkBoldWhite('Your email')}\n` +
`${chalkBoldLabel('Hint')}: Contact information for communication related to the contribution\n` +
` ${chalkBoldLabel('Note:')} This is intended solely for internal communication and will not be shared publicly\n`
});

await pUserEmail.run()
.then((answer:any) => {
userEmail = answer
infoUpdated = true
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});
} while (!userEmail);

const pContributionChanges = new Input({
message: 'Please include any additional details to accompany your pull request: ',
message: `${chalkBoldWhite('Additional information to accompany your pull request)')}\n` +
`${chalkBoldLabel('Hint')}: Information related to the feed's purpose, changes (if updated), use cases and useful references related to the domain/API.\n`,
});

await pContributionChanges.run()
Expand All @@ -171,22 +191,6 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)
process.exit(1);
});

const pUserEmail = new Input({
message: `${chalkBoldWhite('Your email')}\n` +
`${chalkBoldLabel('Hint')}: Contact information for communication related to the contribution\n` +
` Note: This is intended solely for internal communication and will not be shared publicly\n`
});

await pUserEmail.run()
.then((answer:any) => {
userEmail = answer
infoUpdated = true
})
.catch((error:any) => {
Logger.logDetailedError('interrupted...', error)
process.exit(1);
});

// Add the contributionChanges and userEmail to an TESTazureFunctionInfo object
const azureFunctionInfo = {
contributionChanges,
Expand All @@ -197,7 +201,7 @@ const contribute = async (options: ManageFeedClientOptions, optionsSource: any)
info.lastUpdated = new Date().toISOString();
info.contributed = true;

console.log('Updated', info);
Logger.logMessage(`${chalkBoldWhite('Updated Feed Information:')}\n` + prettyJSON(JSON.stringify(info)));

if (infoUpdated) {
const pFeedChanged = new Confirm({
Expand Down

0 comments on commit 2625a8d

Please sign in to comment.