wikiploy 1.6.2 → 1.7.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/README.md +11 -0
- package/assets/test.css +1 -1
- package/assets/test.js +3 -1
- package/package.json +2 -2
- package/src/DeployConfig.js +2 -0
- package/src/Wikiploy.js +1 -1
- package/src/WikiployBase .js +18 -0
- package/src/WikiployLite.js +1 -1
- package/src/ploy_test_full.js +2 -0
- package/src/ploy_test_lite.js +2 -0
- package/test/Wikiploy.test.js +27 -0
package/README.md
CHANGED
|
@@ -10,6 +10,16 @@ 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
|
+
## New options
|
|
14
|
+
|
|
15
|
+
### nowiki (v1.7)
|
|
16
|
+
|
|
17
|
+
Note! It is recomended that you use `nowiki: true` for all JS files. The `nowiki` property is a new option in `DeployConfig` since Wikiploy v1.7.
|
|
18
|
+
|
|
19
|
+
JavaScript page is still a wiki page... Kind of. It can be added to a category or link to other pages. To avoid this use the nowiki option.
|
|
20
|
+
|
|
21
|
+
Don't add this option to CSS though. It won't work correctly.
|
|
22
|
+
|
|
13
23
|
### Wikiploy full
|
|
14
24
|
|
|
15
25
|
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.
|
|
@@ -63,6 +73,7 @@ ployBot.summary = () => {
|
|
|
63
73
|
configs.push(new DeployConfig({
|
|
64
74
|
src: 'test.js',
|
|
65
75
|
dst: '~/test-wikiploy--test.js',
|
|
76
|
+
nowiki: true,
|
|
66
77
|
}));
|
|
67
78
|
await ployBot.deploy(configs);
|
|
68
79
|
})().catch(err => {
|
package/assets/test.css
CHANGED
package/assets/test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiploy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "User scripts and gadgets deployment for MediaWiki (Wikipedia).",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"homepage": "https://github.com/Eccenux/Wikiploy#readme",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"mwn": "2.0.x",
|
|
30
|
-
"puppeteer": "21.
|
|
30
|
+
"puppeteer": "21.4.x"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"bump-version": "0.5.0",
|
package/src/DeployConfig.js
CHANGED
package/src/Wikiploy.js
CHANGED
|
@@ -78,7 +78,7 @@ export default class Wikiploy extends WikiployBase {
|
|
|
78
78
|
let url = this.editUrl(config.dst, config);
|
|
79
79
|
await bot.goto(page, url);
|
|
80
80
|
// insert the content of the file into the edit field
|
|
81
|
-
const contents = await fs.readFile(config.src, 'utf8');
|
|
81
|
+
const contents = this.prepareFile(config, await fs.readFile(config.src, 'utf8'));
|
|
82
82
|
await bot.fillEdit(page, contents);
|
|
83
83
|
// edit description
|
|
84
84
|
const summary = this.prepareSummary(config);
|
package/src/WikiployBase .js
CHANGED
|
@@ -33,6 +33,24 @@ export default class WikiployBase {
|
|
|
33
33
|
return `${summary} • [[en:WP:Wikiploy|Wikiploy]]`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Prepare a text file for wiki.
|
|
38
|
+
*
|
|
39
|
+
* @param {DeployConfig} config Config.
|
|
40
|
+
* @param {String} contents Text file.
|
|
41
|
+
* @returns {String} Edit summary.
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
prepareFile(config, contents) {
|
|
45
|
+
if (config.nowiki) {
|
|
46
|
+
// if (config.src.search(/\.js$/) > 0) {
|
|
47
|
+
// }
|
|
48
|
+
contents = '// <nowiki>\n' + contents + '\n// </nowiki>';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return contents;
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
/** @private Get site for a config. */
|
|
37
55
|
getSite(config) {
|
|
38
56
|
let site = config.site.length ? config.site : this.site;
|
package/src/WikiployLite.js
CHANGED
|
@@ -79,7 +79,7 @@ export default class WikiployLite extends WikiployBase {
|
|
|
79
79
|
// page
|
|
80
80
|
const pageTitle = config.dst;
|
|
81
81
|
// content of the file
|
|
82
|
-
const contents = await fs.readFile(config.src, 'utf8');
|
|
82
|
+
const contents = this.prepareFile(config, await fs.readFile(config.src, 'utf8'));
|
|
83
83
|
// edit description
|
|
84
84
|
const summary = this.prepareSummary(config);
|
|
85
85
|
|
package/src/ploy_test_full.js
CHANGED
|
@@ -11,6 +11,7 @@ const ployBot = new Wikiploy();
|
|
|
11
11
|
configs.push(new DeployConfig({
|
|
12
12
|
src: 'assets/test.js',
|
|
13
13
|
dst: '~/test-jsbot--test.js',
|
|
14
|
+
nowiki: true,
|
|
14
15
|
}));
|
|
15
16
|
configs.push(new DeployConfig({
|
|
16
17
|
src: 'assets/test.css',
|
|
@@ -20,6 +21,7 @@ const ployBot = new Wikiploy();
|
|
|
20
21
|
src: 'assets/test.js',
|
|
21
22
|
dst: '~/test-jsbot--test.js',
|
|
22
23
|
site: 'en.wikipedia.org',
|
|
24
|
+
nowiki: true,
|
|
23
25
|
}));
|
|
24
26
|
configs.push(new DeployConfig({
|
|
25
27
|
src: 'assets/test.css',
|
package/src/ploy_test_lite.js
CHANGED
|
@@ -15,11 +15,13 @@ const ployBot = new WikiployLite(botpass);
|
|
|
15
15
|
configs.push(new DeployConfig({
|
|
16
16
|
src: 'assets/test.js',
|
|
17
17
|
dst: '~/test-wikiploylite--test.js',
|
|
18
|
+
nowiki: true,
|
|
18
19
|
}));
|
|
19
20
|
configs.push(new DeployConfig({
|
|
20
21
|
src: 'assets/test.js',
|
|
21
22
|
dst: '~/test-wikiploylite--test.js',
|
|
22
23
|
site: 'en.wikipedia.org',
|
|
24
|
+
nowiki: true,
|
|
23
25
|
}));
|
|
24
26
|
configs.push(new DeployConfig({
|
|
25
27
|
src: 'assets/test.css',
|
package/test/Wikiploy.test.js
CHANGED
|
@@ -45,4 +45,31 @@ describe('Wikiploy', function () {
|
|
|
45
45
|
assert.equal(summary, expected);
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
describe('prepareFile', function () {
|
|
50
|
+
const ployBot = new Wikiploy();
|
|
51
|
+
function prepareFile(contents, configDef) {
|
|
52
|
+
const config = new DeployConfig(configDef);
|
|
53
|
+
let result = ployBot.prepareFile(config, contents);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
it('should default to no change', function () {
|
|
58
|
+
let file = 'abc def';
|
|
59
|
+
let expected = file;
|
|
60
|
+
const result = prepareFile(file, {
|
|
61
|
+
src: 'test.js',
|
|
62
|
+
});
|
|
63
|
+
assert.equal(result, expected);
|
|
64
|
+
});
|
|
65
|
+
it('should add nowiki to js', function () {
|
|
66
|
+
let file = 'abc def';
|
|
67
|
+
let expected = '// <nowiki>\nabc def\n// </nowiki>';
|
|
68
|
+
const result = prepareFile(file, {
|
|
69
|
+
src: 'test.js',
|
|
70
|
+
nowiki: true,
|
|
71
|
+
});
|
|
72
|
+
assert.equal(result, expected);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
48
75
|
});
|