wikiploy 1.2.2 → 1.3.2
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/DEV.md +49 -0
- package/README.md +47 -4
- package/package.json +3 -3
- 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/DEV.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Development
|
|
2
|
+
==========================
|
|
3
|
+
|
|
4
|
+
Wikiploy is a Node.js project and is configured to use VSCode for development.
|
|
5
|
+
|
|
6
|
+
## Prepararion
|
|
7
|
+
|
|
8
|
+
### Install Node
|
|
9
|
+
Obviously you'll need [Node.JS](https://nodejs.org/en).
|
|
10
|
+
Node 12+ should be fine, but I would probably recommend latest LTS version.
|
|
11
|
+
|
|
12
|
+
Note that you can use [NVM-windows](https://github.com/coreybutler/nvm-windows) if you need multiple Node.js versions installed on Windows.
|
|
13
|
+
|
|
14
|
+
### Install modules
|
|
15
|
+
Run first `npm i`.
|
|
16
|
+
You might want to run `npm up` to update some scripts too.
|
|
17
|
+
|
|
18
|
+
Recomended global modules/tools:
|
|
19
|
+
```
|
|
20
|
+
npm install -g eslint
|
|
21
|
+
npm install -g mocha
|
|
22
|
+
```
|
|
23
|
+
You mostly need above if you will be using your shell (command line).
|
|
24
|
+
|
|
25
|
+
## Running tests
|
|
26
|
+
To run tests in your shell you can use npm: `npm test`. Or just run `mocha`.
|
|
27
|
+
|
|
28
|
+
Better yet install [VSCode](https://code.visualstudio.com/download) and the recommended extenstions. It will make things easier (especially for debugging tests).
|
|
29
|
+
|
|
30
|
+
In VSC, you should see a laboratory flask icon on the sidebar. From there, you can run individual tests or all at once.
|
|
31
|
+
Note that you might need to reload the testing sidebar to see all tests, especially after adding new test files.
|
|
32
|
+
To view output of individual tests use the testing sidebar. Navigate to the test and click on it.
|
|
33
|
+
|
|
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
|
+
|
|
36
|
+
## Publishing
|
|
37
|
+
|
|
38
|
+
Step. 1. Check.
|
|
39
|
+
```
|
|
40
|
+
npm test
|
|
41
|
+
```
|
|
42
|
+
Step. 2. Change version in the package.
|
|
43
|
+
|
|
44
|
+
Step. 3. Final commands.
|
|
45
|
+
```
|
|
46
|
+
npm up
|
|
47
|
+
npm test
|
|
48
|
+
npm publish
|
|
49
|
+
```
|
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,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiploy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "
|
|
8
|
+
"test": "mocha"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -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
|
+
});
|