Skip to content

Commit

Permalink
v2.1: setupSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
Eccenux committed Mar 3, 2024
1 parent 6485eb9 commit 2307af9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wikiploy",
"version": "2.0.1",
"version": "2.1.0",
"description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
"main": "src/index.js",
"type": "module",
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import DeployConfig from './DeployConfig.js';
import WikiployLite from './WikiployLite.js';
import * as verlib from './version.js';
import { userPrompt } from './userPrompt.js';
import { userPrompt, setupSummary } from './userPrompt.js';

const Wikiploy = WikiployLite;

export {
DeployConfig,
verlib,
userPrompt,
setupSummary,
WikiployLite,
Wikiploy
};
25 changes: 24 additions & 1 deletion src/userPrompt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import readline from 'node:readline';
import { stdin as input, stdout as output } from 'node:process';

/**
* Prompt for summary.
* @param {String} prompt Prompt information to display.
* @returns
*/
const userPrompt = (prompt) => {
const rl = readline.createInterface({ input, output });

Expand All @@ -13,4 +18,22 @@ const userPrompt = (prompt) => {
});
};

export { userPrompt };
/**
* Read (prompt) and setup summary.
* @param {WikiployLite} ployBot Bot object (required to setup `summary()`).
* @param {Number} version Gadget version.
* @param {String} standardSummary Standard summary (aside from version).
*/
async function setupSummary(ployBot, version = '', standardSummary = 'changes from Github') {
let info = version.length ? `(empty for a standard summary prefixed with v${version})` : `(empty for a standard summary)`;
let summary = await userPrompt(`Summary of changes ${info}:`);
if (typeof summary !== 'string' || !summary.length) {
summary = standardSummary;
}
ployBot.summary = () => {
return version.length ? `v${version}: ${summary}` : summary;
};
console.log(`[INFO] summary: »${ployBot.summary()}«\n`);
}

export { userPrompt, setupSummary };

0 comments on commit 2307af9

Please sign in to comment.