wikiploy 1.2.2 → 1.3.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/.vscode/extensions.json +6 -0
- package/README.md +47 -4
- package/package.json +2 -2
- package/src/DeployConfig.js +15 -0
- package/src/Wikiploy.js +15 -1
- package/test/DeployConfig.test.js +40 -0
- package/test/Wikiploy.test.js +48 -0
package/README.md
CHANGED
|
@@ -10,13 +10,56 @@ Wikiploy
|
|
|
10
10
|
User scripts and gadgets deployment for wikis (Wikipedia or more generally MediaWiki based wiki).
|
|
11
11
|
Rollout your JS, CSS etc from your git repository to as many MW wikis as you need.
|
|
12
12
|
|
|
13
|
-
This is using [Puppeteer](https://pptr.dev/) to control [Chrome Canary](https://www.google.com/chrome/canary/). You just open Chrome 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.
|
|
13
|
+
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.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
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/).
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Basic script and dst
|
|
18
|
+
```js
|
|
19
|
+
import {DeployConfig, Wikiploy} from 'wikiploy';
|
|
20
|
+
|
|
21
|
+
const ployBot = new Wikiploy();
|
|
22
|
+
|
|
23
|
+
// custom summary
|
|
24
|
+
ployBot.summary = () => {
|
|
25
|
+
return 'v2.7.0: adding new test mode';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// run asynchronusly to be able to wait for results
|
|
29
|
+
(async () => {
|
|
30
|
+
const configs = [];
|
|
31
|
+
configs.push(new DeployConfig({
|
|
32
|
+
src: 'test.js',
|
|
33
|
+
dst: '~/test-wikiploy--test.js',
|
|
34
|
+
}));
|
|
35
|
+
await ployBot.deploy(configs);
|
|
36
|
+
})().catch(err => {
|
|
37
|
+
console.error(err);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Note that `~` will be `User:SomeName` so the user space of currenlty logged in user.
|
|
43
|
+
You can omit `dst` and it will default to `dst: '~/${src}'`.
|
|
44
|
+
|
|
45
|
+
More about this basic code and `dst` in the [Wikiploy rollout example](https://github.com/Eccenux/wikiploy-rollout-example/).
|
|
46
|
+
|
|
47
|
+
## Different wiki sites
|
|
48
|
+
Wikiploy defaults to deployments on `pl.wikipedia.org`.
|
|
49
|
+
|
|
50
|
+
You can change the default like so:
|
|
51
|
+
```js
|
|
52
|
+
ployBot.site = "en.wikipedia.org";
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can also set a site for an indvidual `DeployConfig` like so:
|
|
56
|
+
```js
|
|
57
|
+
configs.push(new DeployConfig({
|
|
58
|
+
src: 'test.js',
|
|
59
|
+
site: "de.wikipedia.org",
|
|
60
|
+
}));
|
|
61
|
+
```
|
|
18
62
|
|
|
19
|
-
I will definitely add more features and handle more use cases.
|
|
20
63
|
|
|
21
64
|
## External links
|
|
22
65
|
* [Wikiploy rollout example (repo)](https://github.com/Eccenux/wikiploy-rollout-example/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiploy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"chai": "^4.3.7",
|
|
32
|
-
"mocha": "^10.2.0",
|
|
32
|
+
"mocha": "^10.2.0",
|
|
33
33
|
"eslint": "^8.43.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/DeployConfig.js
CHANGED
|
@@ -21,6 +21,21 @@ export default class DeployConfig {
|
|
|
21
21
|
if (!this.site || typeof this.site != 'string') {
|
|
22
22
|
this.site = '';
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Custom summary (per file).
|
|
26
|
+
*
|
|
27
|
+
* This can either be a string or a function.
|
|
28
|
+
*
|
|
29
|
+
* Note that you can also set a global summary (for the whole wikiploy).
|
|
30
|
+
* Empty summary will fallback to global summary rules.
|
|
31
|
+
*/
|
|
32
|
+
this.summary = options?.summary;
|
|
33
|
+
if (typeof this.summary === 'string' && this.summary.length) {
|
|
34
|
+
this.summary = () => options.summary;
|
|
35
|
+
}
|
|
36
|
+
if (typeof this.summary != 'function') {
|
|
37
|
+
this.summary = false;
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
/** Does this config require a user. */
|
package/src/Wikiploy.js
CHANGED
|
@@ -135,7 +135,21 @@ export default class Wikiploy {
|
|
|
135
135
|
* @private
|
|
136
136
|
*/
|
|
137
137
|
prepareSummary(config) {
|
|
138
|
-
|
|
138
|
+
let summary = typeof config.summary === 'function' ? config.summary() : this.summary(config);
|
|
139
|
+
return `#Wikiploy ${summary}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Custom summary.
|
|
144
|
+
*
|
|
145
|
+
* This can be e.g. version number and short, text summary.
|
|
146
|
+
* You can use config to add e.g. file name too (which is default).
|
|
147
|
+
*
|
|
148
|
+
* @param {DeployConfig} config Deployment configuration object.
|
|
149
|
+
* @returns {String} Summary added to saved edits.
|
|
150
|
+
*/
|
|
151
|
+
summary(config) {
|
|
152
|
+
return config.src;
|
|
139
153
|
}
|
|
140
154
|
|
|
141
155
|
/**
|
|
@@ -75,4 +75,44 @@ describe('DeployConfig', function () {
|
|
|
75
75
|
assert.equal(result.dst, config.dst);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
describe('summary', function () {
|
|
80
|
+
it('should use string', function () {
|
|
81
|
+
let expected = 'v1.1';
|
|
82
|
+
let config = {
|
|
83
|
+
src: 'test.js',
|
|
84
|
+
summary: expected,
|
|
85
|
+
};
|
|
86
|
+
let result = new DeployConfig(config);
|
|
87
|
+
console.log(result);
|
|
88
|
+
assert.equal(result.summary(), expected);
|
|
89
|
+
});
|
|
90
|
+
it('should use function', function () {
|
|
91
|
+
let expected = 'v1.1: test.js';
|
|
92
|
+
let config = {
|
|
93
|
+
src: 'test.js',
|
|
94
|
+
summary: function() { return `v1.1: ${this.src}`; },
|
|
95
|
+
};
|
|
96
|
+
let result = new DeployConfig(config);
|
|
97
|
+
console.log(result);
|
|
98
|
+
assert.equal(result.summary(), expected);
|
|
99
|
+
});
|
|
100
|
+
it('should default to false', function () {
|
|
101
|
+
let config = {
|
|
102
|
+
src: 'test.js',
|
|
103
|
+
};
|
|
104
|
+
let result = new DeployConfig(config);
|
|
105
|
+
console.log(result);
|
|
106
|
+
assert.equal(result.summary, false);
|
|
107
|
+
});
|
|
108
|
+
it('empty should be ignored', function () {
|
|
109
|
+
let config = {
|
|
110
|
+
src: 'test.js',
|
|
111
|
+
summary: '',
|
|
112
|
+
};
|
|
113
|
+
let result = new DeployConfig(config);
|
|
114
|
+
console.log(result);
|
|
115
|
+
assert.equal(result.summary, false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
78
118
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* global describe, it */
|
|
2
|
+
import { assert } from 'chai';
|
|
3
|
+
import Wikiploy from '../src/Wikiploy.js';
|
|
4
|
+
import DeployConfig from '../src/DeployConfig.js';
|
|
5
|
+
|
|
6
|
+
describe('Wikiploy', function () {
|
|
7
|
+
|
|
8
|
+
describe('summary', function () {
|
|
9
|
+
let tag = '#Wikiploy';
|
|
10
|
+
function prepareSummary(ployBot, configDef) {
|
|
11
|
+
const config = new DeployConfig(configDef);
|
|
12
|
+
console.log({config, summary:config.summary?config.summary():'NN'});
|
|
13
|
+
let summary = ployBot.prepareSummary(config);
|
|
14
|
+
return summary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
it('should use config string', function () {
|
|
18
|
+
let version = 'v1.1';
|
|
19
|
+
let expected = tag + ' ' + version;
|
|
20
|
+
const ployBot = new Wikiploy();
|
|
21
|
+
const summary = prepareSummary(ployBot, {
|
|
22
|
+
src: 'test.js',
|
|
23
|
+
summary: version,
|
|
24
|
+
});
|
|
25
|
+
assert.equal(summary, expected);
|
|
26
|
+
});
|
|
27
|
+
it('should use config function', function () {
|
|
28
|
+
let version = 'v1.2';
|
|
29
|
+
let expected = tag + ' ' + version;
|
|
30
|
+
const ployBot = new Wikiploy();
|
|
31
|
+
const summary = prepareSummary(ployBot, {
|
|
32
|
+
src: 'test.js',
|
|
33
|
+
summary: () => version,
|
|
34
|
+
});
|
|
35
|
+
assert.equal(summary, expected);
|
|
36
|
+
});
|
|
37
|
+
it('should use global function', function () {
|
|
38
|
+
let version = 'v1.3';
|
|
39
|
+
let expected = tag + ' ' + version;
|
|
40
|
+
const ployBot = new Wikiploy();
|
|
41
|
+
ployBot.summary = () => version;
|
|
42
|
+
const summary = prepareSummary(ployBot, {
|
|
43
|
+
src: 'test.js',
|
|
44
|
+
});
|
|
45
|
+
assert.equal(summary, expected);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|