wikiploy 1.9.0 → 2.0.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.
package/DEV.md CHANGED
@@ -38,18 +38,14 @@ You can also run (and debug) each test case directly from a test file. You might
38
38
  Step 1. Check and update versions.
39
39
  ```bash
40
40
  php ./check_up.php
41
+ # npm up
42
+ # npm test
41
43
  ```
42
44
 
43
- Step 2a. Test Puppeteer.
44
- - Open *Chrome Canary* in *debug* mode.
45
- - Run `ploy_test_full.js`.
46
-
47
- Step 2b. Test MWN:
45
+ Step 2. Test MWN:
48
46
  - Run `ploy_test_lite.js`.
49
47
 
50
- Step 3. Final commands.
48
+ Step 3. Publish.
51
49
  ```bash
52
- # npm up
53
- npm test
54
50
  npm publish
55
51
  ```
package/README.md CHANGED
@@ -13,6 +13,20 @@ See also:
13
13
 
14
14
  ## New capabilities
15
15
 
16
+ ### Lightweight Dependencies (v2.0)
17
+
18
+ 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...
19
+
20
+ The only change is that you need to provide bot configuration to Wikiploy (as already described for WikiployLite). It's not nothing, but you only need to follow few steps from the [Botpass configuration section](#botpass-configuration). You only need to do it once and then use in all your user scripts.
21
+
22
+ `WikiployLite` is now synonymous with `Wikiploy`. You can use either of the class names.
23
+
24
+ ### userPrompt (v1.8)
25
+
26
+ Use the `userPrompt` helper function to prompt for a summary in your Wikiploy script. This is only a helper. You can still set up a static summary, but a prompt helps to ensure you don't forget to change the summary.
27
+
28
+ Note that when using `userPrompt` you have to use an interactive terminal. This might be a bit more tricky to set up but can still function as a one-click build from a commandbar (see [README: building your project](https://github.com/Eccenux/Wikiploy/blob/main/README.building%20your%20project.md)).
29
+
16
30
  ### nowiki (v1.7)
17
31
 
18
32
  The `nowiki` property is a new option in `DeployConfig` since Wikiploy v1.7. It is now recommended to use `nowiki: true` for all JS files.
@@ -28,33 +42,26 @@ JavaScript page is still a wiki page... Kind of. It can be added to a category o
28
42
 
29
43
  Don't add this option to CSS though. It won't work correctly.
30
44
 
31
- ### userPrompt (v1.8)
32
-
33
- Use the `userPrompt` helper function to prompt for a summary in your Wikiploy script. This is only a helper. You can still set up a static summary, but a prompt helps to ensure you don't forget to change the summary.
34
-
35
- Note that when using `userPrompt` you have to use an interactive terminal. This might be a bit more tricky to set up but can still function as a one-click build from a commandbar (see [README: building your project](https://github.com/Eccenux/Wikiploy/blob/main/README.building%20your%20project.md)).
45
+ ## Using Wikiploy
36
46
 
37
- ## Wikiploy types
38
-
39
- ### Wikiploy full (deprecated)
40
-
41
- 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.
42
-
43
- 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/).
44
- 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*).
47
+ Either use [Wikiploy project template](https://github.com/Eccenux/wikiploy-rollout-example/releases) or add Wikiploy to your project:
48
+ ```bash
49
+ # npm install wikiploy --save-dev
50
+ npm i wikiploy -D
51
+ ```
45
52
 
46
- ### WikiployLite (recommended)
53
+ The `Wikiploy` class can be used to help deploy scripts. It is using a bot API to do that, but don't worry, you don't need to be a bot ;).
47
54
 
48
- 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.
55
+ You do need to setup a bot password though (on [[Special:BotPasswords]]). It's not as hard as it might seem as **you can do this on *any* Wikimedia wiki and it will work for *all* WMF wikis**. You don't need a bot account for this to work. You will just create an alias for your standard account and a special password just for your scripts.
49
56
 
50
- **WikiployLite** is less memory heavy as it doesn't use a browser (and doesn't use `Puppeteer`). You do need to setup a bot password though (on [[Special:BotPasswords]]). It's not as hard as it might seem as you can do this on any Wikimedia wiki and it will work for all WMF wikis. You don't need a bot account for this to work.
57
+ ## Botpass configuration
58
+ A bot password is essentially a sub-account, designed to help keep your activities separated and secure. Setting up a sub-account is straightforward, and nearly anyone can do it.
51
59
 
52
- Botpass configuration:
53
- * Setup on e.g.: https://test.wikipedia.org/wiki/Special:BotPasswords
54
- * Rights you should setup (if you can): `assets\Bot passwords - Test Wikipedia.png`.
55
- * Example config file in: `assets\public--bot.config.mjs`.
60
+ 1. Begin by setting up your sub-account on this page: [test.wikipedia.org/wiki/Special:BotPasswords](https://test.wikipedia.org/wiki/Special:BotPasswords).
61
+ 2. Choose a name and specify the permissions for your sub-account. For instance, you should grant rights necessary for deploying gadgets (if applicable). You can refer to this example screenshot for setting up rights: [assets\Bot passwords - Test Wikipedia.png](https://github.com/Eccenux/Wikiploy/blob/main/assets/Bot%20passwords%20-%20Test%20Wikipedia.png).
62
+ 3. Next, create your `bot.config.mjs` file. An example configuration file can be found here: `assets\public--bot.config.mjs`.
56
63
 
57
- **Warning!** Never, ever publish your bot password. If you do spill your password, reset/remove the password ASAP (on Special:BotPasswords).
64
+ **Warning!** Never, ever publish your bot password. If you do spill your password, reset/remove the password ASAP (on [Special:BotPasswords](https://test.wikipedia.org/wiki/Special:BotPasswords)).
58
65
 
59
66
 
60
67
  ## Different wiki sites
package/assets/test.css CHANGED
@@ -5,4 +5,4 @@
5
5
  .tavern {
6
6
  display: block;
7
7
  }
8
- /* puppeteer 22.0.0 xor mwn 2.0.2 */
8
+ /*## Wikiploy v2.0.0 with MWN v2.0.2 ##*/
package/assets/test.js CHANGED
@@ -7,4 +7,4 @@
7
7
  */
8
8
  // test.js
9
9
  console.log('test');
10
- /* puppeteer 22.0.0 xor mwn 2.0.2 */
10
+ /*## Wikiploy v2.0.0 with MWN v2.0.2 ##*/
@@ -69,10 +69,28 @@ class UpdateChecker {
69
69
  }
70
70
  }
71
71
 
72
+ /**
73
+ * Check current version.
74
+ *
75
+ * Does a fresh read from JSON.
76
+ *
77
+ * @return $versionFromNpm Version in package.json.
78
+ */
79
+ public function checkMain() {
80
+ $content = file_get_contents('package.json');
81
+ $this->package = json_decode($content, true);
82
+ return $this->package['version'];
83
+ }
84
+
85
+ /**
86
+ * Update test assest with current versions.
87
+ *
88
+ * @param string $path Test asset path.
89
+ */
72
90
  public function updateAsset($path) {
73
91
  $content = file_get_contents($path);
74
- $versionInfo = "/* puppeteer {$this->versions['puppeteer']} xor mwn {$this->versions['mwn']} */";
75
- $content = preg_replace('#/\* puppeteer [0-9.x]+ \w+ mwn [0-9.x]+ \*/#', $versionInfo, $content);
92
+ $versionInfo = "$1 Wikiploy v{$this->package['version']} with MWN v{$this->versions['mwn']} $2";
93
+ $content = preg_replace('@(/\*##).+(##\*/)@', $versionInfo, $content);
76
94
  file_put_contents($path, $content);
77
95
  }
78
96
  }
package/check_up.php CHANGED
@@ -9,17 +9,24 @@ runner('git pull', -1);
9
9
 
10
10
  $versionChecker = new UpdateChecker();
11
11
  // check and update internals
12
- $versionChecker->checkPackage("puppeteer");
12
+ // $versionChecker->checkPackage("puppeteer");
13
13
  $versionChecker->checkPackage("mwn");
14
14
  // save
15
- if ($versionChecker->hasChanges) {
15
+ if (!$versionChecker->hasChanges) {
16
+ echo "\n[INFO] No updates for main deps.\n";
17
+ } else {
16
18
  $versionChecker->save();
19
+
20
+ echo "\n[INFO] Bump version\n";
21
+ runner('npm run bump');
22
+
23
+ $packageVersion = $versionChecker->checkMain(); // check and update internals
24
+ echo "\n[INFO] New version: $packageVersion\n";
17
25
  // update test.js/css (puppeteer/mwn version)
26
+ echo "\n[INFO] Update version in assets\n";
18
27
  $versionChecker->updateAsset('assets/test.css');
19
28
  $versionChecker->updateAsset('assets/test.js');
20
29
 
21
- echo "\n[INFO] Bump version\n";
22
- runner('npm run bump');
23
30
  echo "\n[INFO] Update packages and locks\n";
24
31
  runner('npm up');
25
32
  echo "\n[INFO] Test\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiploy",
3
- "version": "1.9.0",
3
+ "version": "2.0.1",
4
4
  "description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -26,8 +26,7 @@
26
26
  },
27
27
  "homepage": "https://github.com/Eccenux/Wikiploy#readme",
28
28
  "dependencies": {
29
- "mwn": "2.0.x",
30
- "puppeteer": "22.0.x"
29
+ "mwn": "2.0.x"
31
30
  },
32
31
  "devDependencies": {
33
32
  "bump-version": "0.5.0",
package/src/Wikiploy.js CHANGED
@@ -21,6 +21,7 @@ function sleep(sleepMs) {
21
21
  * MediaWiki deployment automation.
22
22
  * Deploy scripts with a browser (puppetter).
23
23
  *
24
+ * @deprecated Use `WikiployLite` instead. WikiployLite will replace Wikiploy.
24
25
  * @property _browser {Browser} Browser connection.
25
26
  */
26
27
  export default class Wikiploy extends WikiployBase {
@@ -19,6 +19,14 @@ export default class WikiployLite extends WikiployBase {
19
19
  constructor(botpass) {
20
20
  super();
21
21
 
22
+ if (typeof botpass != 'object') {
23
+ console.error('Note! Use `botpass` to init config.')
24
+ botpass = {
25
+ username: '__not_provided__',
26
+ password: '__fake__',
27
+ };
28
+ }
29
+
22
30
  /** [[Special:BotPasswords]] data. */
23
31
  this.botpass = {
24
32
  username: botpass.username,
package/src/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import DeployConfig from './DeployConfig.js';
2
- import Wikiploy from './Wikiploy.js';
3
2
  import WikiployLite from './WikiployLite.js';
4
3
  import * as verlib from './version.js';
5
4
  import { userPrompt } from './userPrompt.js';
6
5
 
6
+ const Wikiploy = WikiployLite;
7
+
7
8
  export {
8
9
  DeployConfig,
9
10
  verlib,
@@ -1,6 +1,12 @@
1
1
  import DeployConfig from './DeployConfig.js';
2
2
  import Wikiploy from './Wikiploy.js';
3
3
 
4
+ /**
5
+ Deprecated, do not use.
6
+
7
+ Legacy script that works with Puppeteer.
8
+ */
9
+
4
10
  const ployBot = new Wikiploy();
5
11
  // mock
6
12
  // ployBot.mock = true;
@@ -1,8 +1,14 @@
1
1
  /* global describe, it */
2
2
  import { assert } from 'chai';
3
- import Wikiploy from '../src/Wikiploy.js';
3
+ import { default as Wikiploy } from '../src/WikiployLite.js';
4
4
  import DeployConfig from '../src/DeployConfig.js';
5
5
 
6
+ /** Fake bot auth. */
7
+ const botpass = {
8
+ username: 'test',
9
+ password: 'mock',
10
+ }
11
+
6
12
  describe('Wikiploy', function () {
7
13
 
8
14
  describe('summary', function () {
@@ -17,7 +23,7 @@ describe('Wikiploy', function () {
17
23
  it('should use config string', function () {
18
24
  let version = 'v1.1';
19
25
  let expected = version + ' ' + tag;
20
- const ployBot = new Wikiploy();
26
+ const ployBot = new Wikiploy(botpass);
21
27
  const summary = prepareSummary(ployBot, {
22
28
  src: 'test.js',
23
29
  summary: version,
@@ -27,7 +33,7 @@ describe('Wikiploy', function () {
27
33
  it('should use config function', function () {
28
34
  let version = 'v1.2';
29
35
  let expected = version + ' ' + tag;
30
- const ployBot = new Wikiploy();
36
+ const ployBot = new Wikiploy(botpass);
31
37
  const summary = prepareSummary(ployBot, {
32
38
  src: 'test.js',
33
39
  summary: () => version,
@@ -37,7 +43,7 @@ describe('Wikiploy', function () {
37
43
  it('should use global function', function () {
38
44
  let version = 'v1.3';
39
45
  let expected = version + ' ' + tag;
40
- const ployBot = new Wikiploy();
46
+ const ployBot = new Wikiploy(botpass);
41
47
  ployBot.summary = () => version;
42
48
  const summary = prepareSummary(ployBot, {
43
49
  src: 'test.js',
@@ -47,7 +53,7 @@ describe('Wikiploy', function () {
47
53
  });
48
54
 
49
55
  describe('prepareFile', function () {
50
- const ployBot = new Wikiploy();
56
+ const ployBot = new Wikiploy(botpass);
51
57
  function prepareFile(contents, configDef) {
52
58
  const config = new DeployConfig(configDef);
53
59
  let result = ployBot.prepareFile(config, contents);