wikiploy 1.5.0 → 1.5.3
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/.vscode/commandbar.json +25 -0
- package/.vscode/extensions.json +1 -0
- package/.vscode/launch.json +18 -0
- package/DEV.md +10 -12
- package/assets/test.css +1 -1
- package/assets/test.js +1 -1
- package/check/UpdateChecker.php +78 -0
- package/check/runner.php +24 -0
- package/check_up.php +27 -0
- package/package.json +36 -34
- package/src/WikiOps.js +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Requires `gsppvo.vscode-commandbar`.
|
|
2
|
+
// Also: in settings (UI), `files.associations`, add `commandbar.json: jsonc` (json with comments).
|
|
3
|
+
{
|
|
4
|
+
"skipTerminateQuickPick": true,
|
|
5
|
+
"skipSwitchToOutput": false,
|
|
6
|
+
"skipErrorMessage": true,
|
|
7
|
+
"commands": [
|
|
8
|
+
{
|
|
9
|
+
"text": "test",
|
|
10
|
+
"tooltip": "Run mocha tests.",
|
|
11
|
+
"color": "lightgreen",
|
|
12
|
+
"commandType": "script",
|
|
13
|
+
"command": "test",
|
|
14
|
+
"priority": 0
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"text": "check_up",
|
|
18
|
+
"tooltip": "Check update of main deps.",
|
|
19
|
+
"color": "lightgreen",
|
|
20
|
+
"commandType": "exec",
|
|
21
|
+
"command": "php ./check_up.php",
|
|
22
|
+
"priority": 0
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
package/.vscode/extensions.json
CHANGED
package/.vscode/launch.json
CHANGED
|
@@ -13,6 +13,24 @@
|
|
|
13
13
|
],
|
|
14
14
|
"program": "${workspaceFolder}\\${file}"
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Run current PHP",
|
|
18
|
+
"type": "php",
|
|
19
|
+
"request": "launch",
|
|
20
|
+
"program": "${file}",
|
|
21
|
+
"cwd": "${fileDirname}",
|
|
22
|
+
"externalConsole": false,
|
|
23
|
+
"port": 9003
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Run check_up",
|
|
27
|
+
"type": "php",
|
|
28
|
+
"request": "launch",
|
|
29
|
+
"program": "${workspaceFolder}\\check_up.php",
|
|
30
|
+
"cwd": "${workspaceFolder}",
|
|
31
|
+
"externalConsole": false,
|
|
32
|
+
"port": 9003
|
|
33
|
+
},
|
|
16
34
|
{
|
|
17
35
|
"type": "node",
|
|
18
36
|
"request": "launch",
|
package/DEV.md
CHANGED
|
@@ -35,23 +35,21 @@ You can also run (and debug) each test case directly from a test file. You might
|
|
|
35
35
|
|
|
36
36
|
## Publishing
|
|
37
37
|
|
|
38
|
-
Step
|
|
38
|
+
Step 1. Check and update versions.
|
|
39
39
|
```bash
|
|
40
|
-
|
|
41
|
-
npm test
|
|
40
|
+
php ./check_up.php
|
|
42
41
|
```
|
|
43
|
-
If updating Puppeteer, the also:
|
|
44
|
-
- Change `assets/test.js` and/or css.
|
|
45
|
-
- Run `src/ploy_test_full.js`.
|
|
46
|
-
If updating MWN, the also:
|
|
47
|
-
- Change `assets/test.js` and/or css.
|
|
48
|
-
- Run `src/ploy_test_lite.js`.
|
|
49
42
|
|
|
50
|
-
Step
|
|
43
|
+
Step 2a. Test Puppeteer.
|
|
44
|
+
- Open *Chrome Canary* in *debug* mode.
|
|
45
|
+
- Run `ploy_test_full.js`.
|
|
46
|
+
|
|
47
|
+
Step 2b. Test MWN:
|
|
48
|
+
- Run `ploy_test_lite.js`.
|
|
51
49
|
|
|
52
|
-
Step
|
|
50
|
+
Step 3. Final commands.
|
|
53
51
|
```bash
|
|
54
|
-
npm up
|
|
52
|
+
# npm up
|
|
55
53
|
npm test
|
|
56
54
|
npm publish
|
|
57
55
|
```
|
package/assets/test.css
CHANGED
package/assets/test.js
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Check for updates.
|
|
4
|
+
*/
|
|
5
|
+
class UpdateChecker {
|
|
6
|
+
private $nodeLocks;
|
|
7
|
+
private $package;
|
|
8
|
+
private $cacheNpm;
|
|
9
|
+
public $hasChanges = false;
|
|
10
|
+
/** modified/checked versions */
|
|
11
|
+
public $versions = array();
|
|
12
|
+
|
|
13
|
+
public function __construct() {
|
|
14
|
+
// Read and decode package-lock.json
|
|
15
|
+
$content = file_get_contents('package-lock.json');
|
|
16
|
+
$this->nodeLocks = json_decode($content, true);
|
|
17
|
+
$content = file_get_contents('package.json');
|
|
18
|
+
$this->package = json_decode($content, true);
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Get latest version from npm site (cached). */
|
|
23
|
+
private function getNpmVersion($package) {
|
|
24
|
+
if (empty($this->cacheNpm[$package])) {
|
|
25
|
+
$version = exec("npm view $package version");
|
|
26
|
+
$this->cacheNpm[$package] = trim($version);
|
|
27
|
+
}
|
|
28
|
+
return $this->cacheNpm[$package];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Check package version.
|
|
33
|
+
*
|
|
34
|
+
* @param [type] $package
|
|
35
|
+
* @return $versionFromNpm when updated.
|
|
36
|
+
*/
|
|
37
|
+
public function checkPackage($package) {
|
|
38
|
+
if (!isset($this->nodeLocks['packages']['node_modules/'.$package]['version'])) {
|
|
39
|
+
echo "[ERROR] Package $package not found in package-lock.json.\n";
|
|
40
|
+
// throw new Exception("Unexpected: All packages should be there");
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get version from package-lock.json
|
|
45
|
+
$versionFromLock = $this->nodeLocks['packages']['node_modules/'.$package]['version'];
|
|
46
|
+
$this->versions[$package] = $versionFromLock;
|
|
47
|
+
|
|
48
|
+
// Get version from npm site
|
|
49
|
+
$versionFromNpm = $this->getNpmVersion($package);
|
|
50
|
+
|
|
51
|
+
if ($versionFromLock === $versionFromNpm) {
|
|
52
|
+
echo "[INFO] Versions match for $package (no updates).\n";
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
echo "[INFO] Versions differ for $package: $versionFromLock -> $versionFromNpm\n";
|
|
56
|
+
$this->package['dependencies'][$package] = preg_replace("#[0-9]+$#", "x", $versionFromNpm);
|
|
57
|
+
$this->versions[$package] = $versionFromNpm;
|
|
58
|
+
$this->hasChanges = true;
|
|
59
|
+
return $versionFromNpm;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Update */
|
|
64
|
+
public function save() {
|
|
65
|
+
if ($this->hasChanges) {
|
|
66
|
+
echo "[INFO] Saving changes.\n";
|
|
67
|
+
$data = json_encode($this->package, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
|
68
|
+
file_put_contents('package.json', $data);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public function updateAsset($path) {
|
|
73
|
+
$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);
|
|
76
|
+
file_put_contents($path, $content);
|
|
77
|
+
}
|
|
78
|
+
}
|
package/check/runner.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Simple executioner.
|
|
4
|
+
*
|
|
5
|
+
* @param string $command
|
|
6
|
+
* @param integer $tail
|
|
7
|
+
* @return void
|
|
8
|
+
*/
|
|
9
|
+
function runner($command, $tail=10) {
|
|
10
|
+
exec($command, $output, $retval);
|
|
11
|
+
if ($retval !== 0) {
|
|
12
|
+
echo "[ERROR] Failed to run command ($command) (returned with status $retval)\n";
|
|
13
|
+
} else {
|
|
14
|
+
echo "[INFO] Command ($command) seems OK\n";
|
|
15
|
+
}
|
|
16
|
+
if ($tail > 0) {
|
|
17
|
+
$output = array_slice($output, -$tail);
|
|
18
|
+
}
|
|
19
|
+
foreach($output as $line) {
|
|
20
|
+
echo $line;
|
|
21
|
+
echo "\n";
|
|
22
|
+
}
|
|
23
|
+
echo "\n";
|
|
24
|
+
}
|
package/check_up.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Automated check for updates.
|
|
4
|
+
*/
|
|
5
|
+
require_once "./check/UpdateChecker.php";
|
|
6
|
+
require_once "./check/runner.php";
|
|
7
|
+
|
|
8
|
+
runner('git pull', -1);
|
|
9
|
+
|
|
10
|
+
$versionChecker = new UpdateChecker();
|
|
11
|
+
// check and update internals
|
|
12
|
+
$versionChecker->checkPackage("puppeteer");
|
|
13
|
+
$versionChecker->checkPackage("mwn");
|
|
14
|
+
// save
|
|
15
|
+
if ($versionChecker->hasChanges) {
|
|
16
|
+
$versionChecker->save();
|
|
17
|
+
// update test.js/css (puppeteer/mwn version)
|
|
18
|
+
$versionChecker->updateAsset('assets/test.css');
|
|
19
|
+
$versionChecker->updateAsset('assets/test.js');
|
|
20
|
+
|
|
21
|
+
echo "\n[INFO] Bump version\n";
|
|
22
|
+
runner('npm run bump');
|
|
23
|
+
echo "\n[INFO] Update packages and locks\n";
|
|
24
|
+
runner('npm up');
|
|
25
|
+
echo "\n[INFO] Test\n";
|
|
26
|
+
runner('npm test', 3);
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
"name": "wikiploy",
|
|
3
|
+
"version": "1.5.3",
|
|
4
|
+
"description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"bump": "bump patch",
|
|
9
|
+
"test": "mocha"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Eccenux/Wikiploy.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"Mediawiki",
|
|
17
|
+
"Wikipedia",
|
|
18
|
+
"deploy",
|
|
19
|
+
"rollout",
|
|
20
|
+
"gadgets"
|
|
21
|
+
],
|
|
22
|
+
"author": "Maciej Nux Jaros",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Eccenux/Wikiploy/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Eccenux/Wikiploy#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"mwn": "1.11.x",
|
|
30
|
+
"puppeteer": "21.1.x"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"bump-version": "0.5.0",
|
|
34
|
+
"chai": "4.x",
|
|
35
|
+
"eslint": "8.x",
|
|
36
|
+
"mocha": "10.x"
|
|
37
|
+
}
|
|
36
38
|
}
|