wikibase-cli 16.3.2 → 16.3.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/bin/wb-hub CHANGED
@@ -19,7 +19,7 @@ if (!(/s(ite)?=/.test(argsString))) argsString += ' site=wikidata'
19
19
  if (!(open || urlOnly)) argsString += ' format=json'
20
20
 
21
21
  const query = encodeURIComponent(argsString)
22
- const url = `https://tools.wmflabs.org/hub/query?q=${query}`
22
+ const url = `https://hub.toolforge.org/query?q=${query}`
23
23
 
24
24
  const errors_ = require('../lib/errors')
25
25
 
@@ -56,9 +56,12 @@ module.exports = program => {
56
56
  setElement('object')
57
57
 
58
58
  if (selectLabels) {
59
- if (lang !== 'en') {
60
- // include English as a fallback
61
- lang = `${lang},en`
59
+ // Include [AUTO_LANGUAGE], especially useful if program.open === true
60
+ if (lang === 'en') {
61
+ lang = 'en,[AUTO_LANGUAGE]'
62
+ } else {
63
+ // Include English as a fallback
64
+ lang = `${lang},[AUTO_LANGUAGE],en`
62
65
  }
63
66
  triple += `
64
67
  SERVICE wikibase:label {
@@ -71,7 +74,7 @@ module.exports = program => {
71
74
  let sparql = `SELECT ${select.trim()} WHERE {
72
75
  ${triple}
73
76
  }`
74
- if (limit) sparql += ` LIMIT ${limit}`
77
+ if (limit) sparql += `\nLIMIT ${limit}`
75
78
 
76
79
  return sparql
77
80
  }
@@ -1,19 +1,27 @@
1
1
  const program = require('./program')
2
2
  const { propTypes } = require('./properties')
3
+ const normalizeTypeName = name => name.replace(/-/g, '').toLowerCase()
4
+ const normalizedTypesNames = Object.keys(propTypes).map(normalizeTypeName)
3
5
 
4
6
  module.exports = (pattern, includeTypes) => {
5
7
  const { type } = program
8
+ let normalizedType, isKnownType
9
+ // If --type is called without argument, `type` will be a boolean
10
+ if (typeof type === 'string') {
11
+ normalizedType = normalizeTypeName(type)
12
+ isKnownType = normalizedTypesNames.includes(normalizedType)
13
+ }
6
14
  if (!(pattern && pattern.length > 0)) {
7
- if (typeof type === 'string') {
15
+ if (normalizedType) {
8
16
  // Consider that what was passed as a type argument was actually a pattern
9
- if (!(type.toLowerCase() in propTypes)) pattern = type
17
+ if (!isKnownType) pattern = type
10
18
  } else {
11
19
  return
12
20
  }
13
21
  }
14
22
 
15
- if (includeTypes && pattern.toLowerCase() in propTypes) {
16
- return propData => propData.type === pattern
23
+ if (includeTypes && isKnownType) {
24
+ return propData => normalizeTypeName(propData.type) === normalizedType
17
25
  }
18
26
 
19
27
  // Set the insensitive case flag only if only lowercased was used
@@ -23,8 +31,8 @@ module.exports = (pattern, includeTypes) => {
23
31
  const filterRegex = new RegExp(pattern, flag)
24
32
 
25
33
  let typeFilter
26
- if (typeof type === 'string' && type.toLowerCase() in propTypes) {
27
- typeFilter = propData => propData.type === type
34
+ if (normalizedType && isKnownType) {
35
+ typeFilter = propData => normalizeTypeName(propData.type) === normalizedType
28
36
  } else {
29
37
  typeFilter = () => true
30
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikibase-cli",
3
- "version": "16.3.2",
3
+ "version": "16.3.3",
4
4
  "description": "A command-line interface to Wikibase",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -11,7 +11,6 @@
11
11
  "docker:publish": "./scripts/docker_publish",
12
12
  "lint": "eslint -c .eslintrc bin/wb* lib/* lib/*/* test/* test/lib/*",
13
13
  "lint-staged": "./scripts/lint_staged",
14
- "prepublishOnly": "npm run lint && npm test",
15
14
  "postpublish": "npm run docker:publish && git push --tags",
16
15
  "test": "mocha --exit --timeout 20000 $MOCHA_OPTIONS",
17
16
  "update-toc": "./scripts/update_toc"