wikiploy 1.7.2 → 1.8.0

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.
@@ -0,0 +1,137 @@
1
+ # Building your project
2
+
3
+ There are various ways to build scripts. You can use browserify, webpack, TypeScript compiler etc... or even don't build at all. This is all fine, but not all solution are equally well suite for the wiki world and choosing the right solution takes time.
4
+
5
+ So here is a recommended project setup to save you some time :)
6
+
7
+ Some of this is based on a real script. So if you want you can take a look at [wikibot-jsbot-core](https://github.com/Eccenux/wikibot-jsbot-core). Also you might want to take a look at a template repository for Wikiploy: [wikiploy-rollout-example](https://github.com/Eccenux/wikiploy-rollout-example).
8
+
9
+ ## Recommended setup for building scripts
10
+
11
+ Example `.gitignore` for your project:
12
+ ```
13
+ /node_modules
14
+ *.lnk
15
+ *.priv.*
16
+ bot.config.js
17
+ ```
18
+
19
+ Your `package.json` (crucial part being `scripts`):
20
+ ```js
21
+ {
22
+ "name": "wiki-gadget-yourname",
23
+ "type": "commonjs",
24
+ "scripts": {
25
+ "test": "mocha",
26
+ "build": "browserify src/main.js -o yourname.js",
27
+ "deploy": "node wikiploy.mjs",
28
+ "rollout": "npm run build && npm run deploy"
29
+ },
30
+ "devDependencies": {
31
+ "browserify": "17.x",
32
+ "chai": "4.x",
33
+ "eslint": "8.x",
34
+ "mocha": "10.x"
35
+ },
36
+ "dependencies": {
37
+ "wikiploy": "1.x"
38
+ }
39
+ }
40
+ ```
41
+
42
+ Your `main.js` could look something like this:
43
+ ```js
44
+ var { MyGadget } = require("./MyGadget");
45
+
46
+ // bot instance
47
+ var gadget = new MyGadget();
48
+
49
+ $(function(){
50
+ gadget.init();
51
+ })
52
+ ```
53
+
54
+ ## Visual Studio Code setup
55
+
56
+ [VSC](https://code.visualstudio.com/) is a free editor that over years became almost like an IDE.
57
+
58
+ VSCode helper to install a set of extensions `.vscode/extensions.json`:
59
+ ```
60
+ {
61
+ "recommendations": [
62
+ "gsppvo.vscode-commandbar",
63
+ "hbenl.vscode-test-explorer",
64
+ "hbenl.vscode-mocha-test-adapter"
65
+ ]
66
+ }
67
+ ```
68
+
69
+ VSC settings `.vscode/settings.json`:
70
+ ```
71
+ {
72
+ "search.exclude": {
73
+ "package-lock.json": true,
74
+ },
75
+ "editor.detectIndentation": false,
76
+ "editor.useTabStops": true,
77
+ "editor.insertSpaces": false,
78
+ }
79
+ ```
80
+
81
+ ## Basic script and dst
82
+
83
+ Your minimal `wikiploy.mjs`:
84
+ ```js
85
+ import {DeployConfig, WikiployLite, userPrompt} from 'wikiploy';
86
+
87
+ import * as botpass from './bot.config.js';
88
+ const ployBot = new WikiployLite(botpass);
89
+
90
+ // default site for DeployConfig
91
+ ployBot.site = "en.wikipedia.org";
92
+
93
+ // run asynchronously to be able to wait for results
94
+ (async () => {
95
+ // Note! The `userPrompt` requires an interactive terminal.
96
+ // In VSC you can use tasks to get an interactive terminal and still run wikiploy from your commandbar.
97
+ const summary = await userPrompt('Summary of changes (empty for default summary):');
98
+ if (typeof summary === 'string' && summary.length) {
99
+ ployBot.summary = () => {
100
+ return summary;
101
+ }
102
+ }
103
+
104
+ // push out file(s) to wiki
105
+ const configs = [];
106
+ configs.push(new DeployConfig({
107
+ src: 'test.js',
108
+ dst: '~/test-wikiploy--test.js',
109
+ nowiki: true,
110
+ }));
111
+ await ployBot.deploy(configs);
112
+ })().catch(err => {
113
+ console.error(err);
114
+ process.exit(1);
115
+ });
116
+ ```
117
+
118
+ Note that `~` will be `User:SomeName` so the user space of a currently logged in user (you user space).
119
+ You can omit `dst` and it will default to `dst: '~/${src}'`.
120
+
121
+ More about this basic code and `dst` in the [Wikiploy rollout example](https://github.com/Eccenux/wikiploy-rollout-example/).
122
+
123
+ ## Exporting stuff
124
+
125
+ Your `main.js` could look something like this:
126
+ ```js
127
+ var { MyGadget } = require("./MyGadget");
128
+
129
+ // bot instance
130
+ var gadget = new MyGadget();
131
+
132
+ $(function(){
133
+ gadget.init();
134
+ })
135
+ ```
136
+
137
+ Note that browserify will wrap your code with a function automatically. So you don't have to worry about leaking variables to global scope.
package/README.md CHANGED
@@ -1,33 +1,40 @@
1
1
  Wikiploy
2
2
  ==========================
3
3
 
4
- ## Polski opis
4
+ Wikiploy is a one-click solution to deploy JS and CSS to Wikipedia.
5
5
 
6
- [Wikipedia:Wikiploy](https://pl.wikipedia.org/wiki/Wikipedia:Wikiploy)
6
+ After initial setup you can quickly build and deploy your user scripts and gadgets. Thought this was designed to work with Wikipedia you should be able to deploy to any [MediaWiki](https://www.mediawiki.org/) based wiki. You can even deploy to multiple websites with one-click (to whatever you have access to).
7
7
 
8
- ## English description
8
+ See also:
9
9
 
10
- User scripts and gadgets deployment for wikis (Wikipedia or more generally MediaWiki based wiki).
11
- Rollout your JS, CSS etc from your git repository to as many MW wikis as you need.
10
+ - [README: building your project](README.building your project.md) recommendation on how to build JS and CSS for your gadgets.
11
+ - [Wikipedia:Wikiploy on pl.wiki](https://pl.wikipedia.org/wiki/Wikipedia:Wikiploy) for Polish description.
12
+ - (more links on the bottom)
12
13
 
13
- ## New options
14
+ ## New capabilities
14
15
 
15
16
  ### nowiki (v1.7)
16
17
 
17
- Note! It is recomended that you use `nowiki: true` for all JS files. The `nowiki` property is a new option in `DeployConfig` since Wikiploy v1.7.
18
+ Note! It is recommended that you use `nowiki: true` for all JS files. The `nowiki` property is a new option in `DeployConfig` since Wikiploy v1.7.
18
19
 
19
20
  JavaScript page is still a wiki page... Kind of. It can be added to a category or link to other pages. To avoid this use the nowiki option.
20
21
 
21
22
  Don't add this option to CSS though. It won't work correctly.
22
23
 
23
- ### Wikiploy full
24
+ ### userPrompt (v1.8)
25
+
26
+ Prompt for summary so that you don't forget to change it. This is a bit more tricky to setup, but can still work as a one-click build (see [README: building your project](README.building your project.md)).
27
+
28
+ ## Wikiploy types
29
+
30
+ ### Wikiploy full (deprecated)
24
31
 
25
32
  This is using [Puppeteer](https://pptr.dev/) to control [Chrome Canary](https://www.google.com/chrome/canary/) or similar. You just open Chrome with remote debug enabled and run a script. The idea is that you are logged in in Chrome and so all edits are still your edits. You can keep the Canary running in the background when you are changing and deploying more stuff.
26
33
 
27
34
  Wikiploy will also work with other Chromium based browser. [Instructions for enabling remote debug in MS Edge](https://learn.microsoft.com/en-us/microsoft-edge/devtools-protocol-chromium/).
28
35
  Note that to completely close Edge you might need use settings: Continue running in background when Microsoft Edge is closed (pl. *Kontynuuj działanie aplikacji i rozszerzeń w tle po zamknięciu przeglądarki Microsoft Edge*).
29
36
 
30
- ### WikiployLite
37
+ ### WikiployLite (recommended)
31
38
 
32
39
  The `WikiployLite` class is using a bot API to deploy scripts. You can use standard `Wikiploy` and `WikiployLite` interchangeably. The `DeployConfig` is the same. WikiployLite is recommended as long as you can use it.
33
40
 
@@ -40,52 +47,6 @@ Botpass configuration:
40
47
 
41
48
  **Warning!** Never, ever publish your bot password. If you do spill your password, reset/remove the password ASAP (on Special:BotPasswords).
42
49
 
43
- Example `.gitignore` for your project:
44
- ```
45
- /node_modules
46
- *.lnk
47
- *.priv.*
48
- bot.config.js
49
- ```
50
-
51
- ## Basic script and dst
52
- ```js
53
- import {DeployConfig, Wikiploy, WikiployLite, verlib} from 'wikiploy';
54
-
55
- // full
56
- //const ployBot = new Wikiploy();
57
- // lite
58
- import * as botpass from './bot.config.js';
59
- const ployBot = new WikiployLite(botpass);
60
-
61
- // extra if you want to read your version from the package.json
62
- const version = await verlib.readVersion('./package.json');
63
-
64
- // custom summary
65
- ployBot.summary = () => {
66
- //return 'v2.7.0: adding new test mode';
67
- return `v${version}: adding new test mode`;
68
- }
69
-
70
- // run asynchronously to be able to wait for results
71
- (async () => {
72
- const configs = [];
73
- configs.push(new DeployConfig({
74
- src: 'test.js',
75
- dst: '~/test-wikiploy--test.js',
76
- nowiki: true,
77
- }));
78
- await ployBot.deploy(configs);
79
- })().catch(err => {
80
- console.error(err);
81
- process.exit(1);
82
- });
83
- ```
84
-
85
- Note that `~` will be `User:SomeName` so the user space of a currently logged in user (you user space).
86
- You can omit `dst` and it will default to `dst: '~/${src}'`.
87
-
88
- More about this basic code and `dst` in the [Wikiploy rollout example](https://github.com/Eccenux/wikiploy-rollout-example/).
89
50
 
90
51
  ## Different wiki sites
91
52
  Wikiploy defaults to deployments on `pl.wikipedia.org`.
package/assets/test.css CHANGED
@@ -5,4 +5,4 @@
5
5
  .tavern {
6
6
  display: block;
7
7
  }
8
- /* puppeteer 21.5.2 xor mwn 2.0.1 */
8
+ /* puppeteer 21.6.1 xor mwn 2.0.2 */
package/assets/test.js CHANGED
@@ -7,4 +7,4 @@
7
7
  */
8
8
  // test.js
9
9
  console.log('test');
10
- /* puppeteer 21.5.2 xor mwn 2.0.1 */
10
+ /* puppeteer 21.6.1 xor mwn 2.0.2 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiploy",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "homepage": "https://github.com/Eccenux/Wikiploy#readme",
28
28
  "dependencies": {
29
29
  "mwn": "2.0.x",
30
- "puppeteer": "21.5.x"
30
+ "puppeteer": "21.6.x"
31
31
  },
32
32
  "devDependencies": {
33
33
  "bump-version": "0.5.0",
package/src/index.js CHANGED
@@ -2,10 +2,12 @@ import DeployConfig from './DeployConfig.js';
2
2
  import Wikiploy from './Wikiploy.js';
3
3
  import WikiployLite from './WikiployLite.js';
4
4
  import * as verlib from './version.js';
5
+ import { userPrompt } from './userPrompt.js';
5
6
 
6
7
  export {
7
8
  DeployConfig,
8
9
  verlib,
10
+ userPrompt,
9
11
  WikiployLite,
10
12
  Wikiploy
11
13
  };
@@ -0,0 +1,16 @@
1
+ import readline from 'node:readline';
2
+ import { stdin as input, stdout as output } from 'node:process';
3
+
4
+ const userPrompt = (prompt) => {
5
+ const rl = readline.createInterface({ input, output });
6
+
7
+ return new Promise((resolve) => {
8
+ rl.question(prompt, (summary) => {
9
+ rl.close();
10
+
11
+ resolve(summary);
12
+ });
13
+ });
14
+ };
15
+
16
+ export { userPrompt };