diff --git a/package-lock.json b/package-lock.json index 935e859..37ad023 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wikiploy", - "version": "2.0.1", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wikiploy", - "version": "2.0.1", + "version": "2.1.0", "license": "MIT", "dependencies": { "mwn": "2.0.x" diff --git a/package.json b/package.json index 1dfbe37..f3962d5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 43129b0..0044b12 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ 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; @@ -9,6 +9,7 @@ export { DeployConfig, verlib, userPrompt, + setupSummary, WikiployLite, Wikiploy }; \ No newline at end of file diff --git a/src/userPrompt.js b/src/userPrompt.js index 05d181f..0d18bab 100644 --- a/src/userPrompt.js +++ b/src/userPrompt.js @@ -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 }); @@ -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 };