wikiploy 2.0.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,11 +34,9 @@ Your `package.json` (crucial part being `scripts`):
34
34
  "chai": "4.x",
35
35
  "eslint": "8.x",
36
36
  "less": "4.x",
37
- "mocha": "10.x"
37
+ "mocha": "10.x",
38
+ "wikiploy": "2.x"
38
39
  },
39
- "dependencies": {
40
- "wikiploy": "1.x"
41
- }
42
40
  }
43
41
  ```
44
42
 
package/README.md CHANGED
@@ -7,12 +7,50 @@ After the initial setup, you can quickly build and deploy your user scripts and
7
7
 
8
8
  See also:
9
9
 
10
- - [README: building your project](https://github.com/Eccenux/Wikiploy/blob/main/README.building%20your%20project.md) recommendation on how to build JS and CSS for your gadgets (includes unit testing setup).
11
- - [Wikipedia:Wikiploy on pl.wiki](https://pl.wikipedia.org/wiki/Wikipedia:Wikiploy) for Polish description.
10
+ - [Wikiploy project template](https://github.com/Eccenux/wikiploy-rollout-example/releases) quick start for you gadgets.
11
+ - [README: building your project](https://github.com/Eccenux/Wikiploy/blob/main/README.building%20your%20project.md) — recommendation on how to build JS and CSS for your gadgets (includes unit testing setup).
12
+ - [Wikipedia:Wikiploy on pl.wiki](https://pl.wikipedia.org/wiki/Wikipedia:Wikiploy) — Polish description.
12
13
  - (more links on the bottom)
13
14
 
14
15
  ## New capabilities
15
16
 
17
+ ### setupSummary (v2.1)
18
+
19
+ A helper function that can replace your usages of `userPrompt`. It prompts a user and then supplies
20
+ The `setupSummary` function initializes a summary for a given bot. It requires a `Wikiploy` bot object and optionally takes a gadget version and a standard summary text.
21
+
22
+ #### Parameters
23
+
24
+ - `ployBot`: A `Wikiploy` bot object. This is required to setup the `summary()` function.
25
+ - `version` (optional): The version of your gadget. Defaults to an empty string if not provided.
26
+ - `standardSummary` (optional): A string that provides a standard summary aside from the version. Defaults to "changes from Github".
27
+
28
+ For a prompt answer: "fixed bug #123", you would get: "v5.6.0: fixed bug #123" (`v${version}: ${summary}`).
29
+
30
+ #### Usage
31
+
32
+ Basic usage:
33
+ ```js
34
+ // custom summary from a prompt
35
+ await setupSummary(ployBot);
36
+ ```
37
+
38
+ Version from package:
39
+ ```js
40
+ (async () => {
41
+ // custom summary from a prompt
42
+ let version = await readVersion('package.json');
43
+ await setupSummary(ployBot, version);
44
+
45
+ // [...]
46
+
47
+ await ployBot.deploy(configs);
48
+ })().catch(err => {
49
+ console.error(err);
50
+ process.exit(1);
51
+ });
52
+ ```
53
+
16
54
  ### Lightweight Dependencies (v2.0)
17
55
 
18
56
  We had a good run, but it's time to bid farewell to [Puppeteer](https://pptr.dev/) and free the puppets ;). Obviously, this might be a breaking change if you really need to use it. However, the Wikiploy API doesn't really change...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiploy",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import DeployConfig from './DeployConfig.js';
2
2
  import WikiployLite from './WikiployLite.js';
3
3
  import * as verlib from './version.js';
4
- import { userPrompt } from './userPrompt.js';
4
+ import { userPrompt, setupSummary } from './userPrompt.js';
5
5
 
6
6
  const Wikiploy = WikiployLite;
7
7
 
@@ -9,6 +9,7 @@ export {
9
9
  DeployConfig,
10
10
  verlib,
11
11
  userPrompt,
12
+ setupSummary,
12
13
  WikiployLite,
13
14
  Wikiploy
14
15
  };
package/src/userPrompt.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import readline from 'node:readline';
2
2
  import { stdin as input, stdout as output } from 'node:process';
3
3
 
4
+ /**
5
+ * Prompt for summary.
6
+ * @param {String} prompt Prompt information to display.
7
+ * @returns
8
+ */
4
9
  const userPrompt = (prompt) => {
5
10
  const rl = readline.createInterface({ input, output });
6
11
 
@@ -13,4 +18,22 @@ const userPrompt = (prompt) => {
13
18
  });
14
19
  };
15
20
 
16
- export { userPrompt };
21
+ /**
22
+ * Read (prompt) and setup summary.
23
+ * @param {WikiployLite} ployBot Bot object (required to setup `summary()`).
24
+ * @param {Number} version Gadget version.
25
+ * @param {String} standardSummary Standard summary (aside from version).
26
+ */
27
+ async function setupSummary(ployBot, version = '', standardSummary = 'changes from Github') {
28
+ let info = version.length ? `(empty for a standard summary prefixed with v${version})` : `(empty for a standard summary)`;
29
+ let summary = await userPrompt(`Summary of changes ${info}:`);
30
+ if (typeof summary !== 'string' || !summary.length) {
31
+ summary = standardSummary;
32
+ }
33
+ ployBot.summary = () => {
34
+ return version.length ? `v${version}: ${summary}` : summary;
35
+ };
36
+ console.log(`[INFO] summary: »${ployBot.summary()}«\n`);
37
+ }
38
+
39
+ export { userPrompt, setupSummary };