wikibase-cli 15.16.0 → 15.16.4
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 +2 -0
- package/bin/wd +9 -2
- package/lib/output.js +7 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ This tool is mostly a CLI interface to the JS modules [wikibase-edit](https://ww
|
|
|
5
5
|
|
|
6
6
|
It was primarily developed to target [Wikidata](https://wikidata.org), but as then been decoupled to support any Wikibase instance.
|
|
7
7
|
|
|
8
|
+
Supported systems: any system that can run [NodeJS](https://nodejs.org/en/download/) (Linux, Mac OS, Windows, and more)
|
|
9
|
+
|
|
8
10
|
This project received [a Wikimedia Project Grant](https://meta.wikimedia.org/wiki/Grants:Project/WikidataJS).
|
|
9
11
|
|
|
10
12
|
<div align="center">
|
package/bin/wd
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
process.env.WB_INSTANCE = 'https://www.wikidata.org'
|
|
4
|
+
process.env.WB_SPARQL_ENDPOINT = 'https://query.wikidata.org/sparql'
|
|
5
|
+
// Fake the executed script to be wb to trick commander to believe it
|
|
6
|
+
// as it would otherwise fail to build subcommand paths
|
|
7
|
+
process.argv[1] = process.argv[1].replace(/wd$/, 'wb')
|
|
8
|
+
|
|
9
|
+
require('./wb')
|
package/lib/output.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const types = require('./types')
|
|
2
|
+
const { promisify } = require('util')
|
|
3
|
+
const stdoutWrite = promisify(process.stdout.write).bind(process.stdout)
|
|
2
4
|
|
|
3
5
|
// Calling program just in time, so that code running
|
|
4
6
|
// after this first level function can still change the option
|
|
5
|
-
module.exports = program => (data, optional, customColors) => {
|
|
7
|
+
module.exports = program => async (data, optional, customColors) => {
|
|
6
8
|
const isArray = types.isArray(data)
|
|
7
9
|
const isPlainObject = types.isPlainObject(data)
|
|
8
10
|
const isCollection = types.isCollection(data)
|
|
@@ -16,7 +18,7 @@ module.exports = program => (data, optional, customColors) => {
|
|
|
16
18
|
if (optional) {
|
|
17
19
|
if (!program.verbose) return
|
|
18
20
|
if (!customColors) data = require('chalk').grey(data)
|
|
19
|
-
log(data)
|
|
21
|
+
await log(data)
|
|
20
22
|
} else {
|
|
21
23
|
if (isArray && !isCollection && !program.json) {
|
|
22
24
|
if (program.format === 'inline') data = data.join(' ')
|
|
@@ -36,16 +38,16 @@ module.exports = program => (data, optional, customColors) => {
|
|
|
36
38
|
if (program.clipboard) {
|
|
37
39
|
require('./copy')(data)
|
|
38
40
|
} else {
|
|
39
|
-
log(data)
|
|
41
|
+
await log(data)
|
|
40
42
|
process.exit(0)
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
const log = data => {
|
|
47
|
+
const log = async data => {
|
|
46
48
|
if (typeof data === 'string') {
|
|
47
49
|
if (!data.endsWith('\n')) data += '\n'
|
|
48
|
-
|
|
50
|
+
await stdoutWrite(data)
|
|
49
51
|
} else {
|
|
50
52
|
console.log(data)
|
|
51
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikibase-cli",
|
|
3
|
-
"version": "15.16.
|
|
3
|
+
"version": "15.16.4",
|
|
4
4
|
"description": "A command-line interface to Wikibase",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lint-staged": "./scripts/lint_staged",
|
|
14
14
|
"prepublishOnly": "npm run lint && npm test",
|
|
15
15
|
"postpublish": "npm run docker:publish && git push --tags",
|
|
16
|
-
"test": "mocha --exit --timeout 20000",
|
|
16
|
+
"test": "mocha --exit --timeout 20000 $MOCHA_OPTIONS",
|
|
17
17
|
"update-toc": "./scripts/update_toc"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|