wikiploy 2.1.4 → 2.2.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.
@@ -2,6 +2,8 @@
2
2
  "recommendations": [
3
3
  "gsppvo.vscode-commandbar",
4
4
  "hbenl.vscode-test-explorer",
5
- "hbenl.vscode-mocha-test-adapter"
5
+ "hbenl.vscode-mocha-test-adapter",
6
+ "xdebug.php-debug",
7
+ "recca0120.vscode-phpunit"
6
8
  ]
7
9
  }
package/DEV.md CHANGED
@@ -33,6 +33,14 @@ To view output of individual tests use the testing sidebar. Navigate to the test
33
33
 
34
34
  You can also run (and debug) each test case directly from a test file. You might need to press reload in the sidebar if you don't see buttons to run and debug tests.
35
35
 
36
+ ## PHP tests
37
+
38
+ ```powershell
39
+ #composer update
40
+ composer install
41
+ composer test
42
+ ```
43
+
36
44
  ## Publishing
37
45
 
38
46
  Step 1. Check and update versions.
package/README.md CHANGED
@@ -1,11 +1,30 @@
1
1
  Wikiploy
2
2
  ==========================
3
3
 
4
- Wikiploy is a one-click solution to deploy JS and CSS to Wikipedia.
4
+ Wikiploy is a one-click solution to deploy JS and CSS to Wikipedia. It uses NodeJS version 14 or higher.
5
5
 
6
6
  After the initial setup, you can quickly build and deploy your user scripts and gadgets. Though 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 just one click on your commandbar. Your only limitation is your access level to the wikis.
7
7
 
8
- See also:
8
+ ## Table of contents
9
+ <!-- TOC depthfrom:2 updateonsave:false -->
10
+
11
+ - [Table of contents](#table-of-contents)
12
+ - [See also](#see-also)
13
+ - [New capabilities](#new-capabilities)
14
+ - [setupSummary v2.1](#setupsummary-v21)
15
+ - [Parameters](#parameters)
16
+ - [Usage](#usage)
17
+ - [Lightweight Dependencies v2.0](#lightweight-dependencies-v20)
18
+ - [userPrompt v1.8](#userprompt-v18)
19
+ - [nowiki v1.7](#nowiki-v17)
20
+ - [Using Wikiploy](#using-wikiploy)
21
+ - [Botpass configuration](#botpass-configuration)
22
+ - [Different wiki sites](#different-wiki-sites)
23
+ - [External links](#external-links)
24
+
25
+ <!-- /TOC -->
26
+
27
+ ## See also
9
28
 
10
29
  - [Wikiploy project template](https://github.com/Eccenux/wikiploy-rollout-example/releases) — quick start for you gadgets.
11
30
  - [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).
package/assets/test.css CHANGED
@@ -5,4 +5,4 @@
5
5
  .tavern {
6
6
  display: block;
7
7
  }
8
- /*## Wikiploy v2.1.4 with MWN v2.0.2 ##*/
8
+ /*## Wikiploy v2.2.0 with MWN v3.0.1 ##*/
package/assets/test.js CHANGED
@@ -7,4 +7,4 @@
7
7
  */
8
8
  // test.js
9
9
  console.log('test');
10
- /*## Wikiploy v2.1.4 with MWN v2.0.2 ##*/
10
+ /*## Wikiploy v2.2.0 with MWN v3.0.1 ##*/
@@ -1,4 +1,6 @@
1
1
  <?php
2
+ namespace Wikiploy;
3
+
2
4
  /**
3
5
  * Check for updates.
4
6
  */
@@ -93,4 +95,43 @@ class UpdateChecker {
93
95
  $content = preg_replace('@(/\*##).+(##\*/)@', $versionInfo, $content);
94
96
  file_put_contents($path, $content);
95
97
  }
98
+
99
+ /**
100
+ * Update a script with version.
101
+ *
102
+ * @param string $path I/O path.
103
+ */
104
+ public function updateScript($path, $vName, $version) {
105
+ $input = file_get_contents($path);
106
+ $content = self::updateScriptContent($input, $vName, $version);
107
+ file_put_contents($path, $content);
108
+ }
109
+ /**
110
+ * Update input text with named version.
111
+ *
112
+ * @param string $input Input.
113
+ * @param string $vName Name of the version (added in marker).
114
+ * @param string $version New version number.
115
+ */
116
+ public static function updateScriptContent($input, $vName, $version):string {
117
+ // Example:
118
+ // /*version:vName:*/''/*:vName:version*/
119
+ $content = preg_replace_callback(
120
+ '@(/\*version:'.$vName.':\*/)(?:(\')[^\']*\'|(")[^"]*")(/\*:'.$vName.':version\*/)@',
121
+ function ($matches) use ($version) {
122
+ $qt = !empty($matches[2]) ? $matches[2] : $matches[3];
123
+ return $matches[1].$qt.$version.$qt.$matches[4];
124
+ },
125
+ $input
126
+ );
127
+ return $content;
128
+ }
96
129
  }
130
+
131
+ // quick debug
132
+ // $input = "const version = /*version:main:*/''/*:main:version*/;";
133
+ // $expected = "const version = /*version:main:*/'3.0.0'/*:main:version*/;";
134
+ // $result = UpdateChecker::updateScriptContent($input, 'main', '3.0.0');
135
+ // echo "\n e: $expected";
136
+ // echo "\n r: $result";
137
+
package/check/runner.php CHANGED
@@ -1,4 +1,6 @@
1
1
  <?php
2
+ namespace Wikiploy;
3
+
2
4
  /**
3
5
  * Simple executioner.
4
6
  *
package/check_up.php CHANGED
@@ -1,4 +1,6 @@
1
1
  <?php
2
+ namespace Wikiploy;
3
+
2
4
  /**
3
5
  * Automated check for updates.
4
6
  */
@@ -9,28 +11,35 @@ runner('git pull', -1);
9
11
 
10
12
  $options = getopt("", ["force"]);
11
13
 
12
- $versionChecker = new UpdateChecker();
14
+ $upChecker = new UpdateChecker();
15
+
16
+ // update package version
17
+ $packageVersion = $upChecker->checkMain();
18
+ $upChecker->updateScript("./src/WikiployLite.js", "main", $packageVersion);
19
+
13
20
  // check and update internals
14
- // $versionChecker->checkPackage("puppeteer");
15
- $versionChecker->checkPackage("mwn");
21
+ // $upChecker->checkPackage("puppeteer");
22
+ $upChecker->checkPackage("mwn");
16
23
  // save
17
- if (!isset($options['force']) && !$versionChecker->hasChanges) {
24
+ if (!isset($options['force']) && !$upChecker->hasChanges) {
18
25
  echo "\n[INFO] No updates for main deps.\n";
19
26
  } else {
20
- $versionChecker->save();
27
+ $upChecker->save();
21
28
 
22
29
  echo "\n[INFO] Bump version\n";
23
30
  runner('npm run bump');
24
31
 
25
- $packageVersion = $versionChecker->checkMain(); // check and update internals
32
+ $packageVersion = $upChecker->checkMain(); // check and update internals
26
33
  echo "\n[INFO] New version: $packageVersion\n";
34
+ // re-update package version
35
+ $upChecker->updateScript("./src/WikiployLite.js", "main", $packageVersion);
27
36
  // update test.js/css (puppeteer/mwn version)
28
37
  echo "\n[INFO] Update version in assets\n";
29
- $versionChecker->updateAsset('assets/test.css');
30
- $versionChecker->updateAsset('assets/test.js');
38
+ $upChecker->updateAsset('assets/test.css');
39
+ $upChecker->updateAsset('assets/test.js');
31
40
 
32
41
  echo "\n[INFO] Update packages and locks\n";
33
42
  runner('npm up');
34
43
  echo "\n[INFO] Test\n";
35
44
  runner('npm test', 3);
36
- }
45
+ }
package/composer.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "nux/wikiploy",
3
+ "type": "project",
4
+ "require-dev": {
5
+ "phpunit/phpunit": "^11.0"
6
+ },
7
+ "autoload": {
8
+ "psr-4": {
9
+ "Wikiploy\\": "check/"
10
+ }
11
+ },
12
+ "autoload-dev": {
13
+ "psr-4": {
14
+ "Wikiploy\\Tests\\": "test/"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "test": "phpunit"
19
+ }
20
+ }