wikibase-cli 16.1.2 → 16.2.0

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.
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ const program = require('commander')
3
+ const polymorphicCommandArgsParser = require('../lib/polymorphic_command_args_parser')
4
+ const inlineArgsParser = ([ id, language ]) => {
5
+ return [ { id, language, value: null } ]
6
+ }
7
+ program.customArgsParser = polymorphicCommandArgsParser(inlineArgsParser)
8
+ program.customHelpOption = require('../lib/command_with_template_custom_help')
9
+ require('../lib/edit/edit_command')({
10
+ name: 'remove-description',
11
+ section: 'description',
12
+ action: 'set',
13
+ })
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ const program = require('commander')
3
+ const polymorphicCommandArgsParser = require('../lib/polymorphic_command_args_parser')
4
+ const inlineArgsParser = ([ id, language ]) => {
5
+ return [ { id, language, value: null } ]
6
+ }
7
+ program.customArgsParser = polymorphicCommandArgsParser(inlineArgsParser)
8
+ program.customHelpOption = require('../lib/command_with_template_custom_help')
9
+ require('../lib/edit/edit_command')({
10
+ name: 'remove-label',
11
+ section: 'label',
12
+ action: 'set',
13
+ })
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ const program = require('commander')
3
+ const polymorphicCommandArgsParser = require('../lib/polymorphic_command_args_parser')
4
+ const inlineArgsParser = ([ id, site ]) => {
5
+ return [ { id, site, title: null } ]
6
+ }
7
+ program.customArgsParser = polymorphicCommandArgsParser(inlineArgsParser)
8
+ program.customHelpOption = require('../lib/command_with_template_custom_help')
9
+ require('../lib/edit/edit_command')({
10
+ name: 'remove-sitelink',
11
+ section: 'sitelink',
12
+ action: 'set',
13
+ })
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ const program = require('commander')
3
+ const polymorphicCommandArgsParser = require('../lib/polymorphic_command_args_parser')
4
+ const inlineArgsParser = ([ id, site, title, badges = '' ]) => {
5
+ return [ { id, site, title, badges: badges.split(/[,|]/) } ]
6
+ }
7
+ program.customArgsParser = polymorphicCommandArgsParser(inlineArgsParser)
8
+ program.customHelpOption = require('../lib/command_with_template_custom_help')
9
+ require('../lib/edit/edit_command')('sitelink', 'set')
@@ -10,7 +10,15 @@ const { red } = require('chalk')
10
10
  const { inspect } = require('util')
11
11
 
12
12
  module.exports = async (section, action) => {
13
- const name = `${action}-${section}`
13
+ let name
14
+ if (typeof section === 'object') {
15
+ // Pass a name when it can not be deduced from the wikibase-edit section
16
+ // and action name, typically when a command uses a wikibase-edit function
17
+ // but with a different name
18
+ ;({ name, section, action } = section)
19
+ } else {
20
+ name = `${action}-${section}`
21
+ }
14
22
  program.process(name)
15
23
 
16
24
  if (program.showHelp) return program.customHelpOption()
@@ -13,6 +13,7 @@ const simplifyOptions = {
13
13
  keepNonTruthy: true,
14
14
  keepSnaktypes: true,
15
15
  keepRanks: true,
16
+ keepBadges: true,
16
17
  // No need to keep the hashes as every edited claim (identified with a GUID)
17
18
  // will have it's qualifiers and references fully overriden
18
19
  keepHashes: false
@@ -37,6 +38,18 @@ const FormatEntity = (batchMode, propsToPick, requestedPropsAndSubProps, minimiz
37
38
  if (createMode) delete entity.id
38
39
  entity = pick(entity, propsToPick)
39
40
  dropNonSelectedSubprops(entity, requestedPropsAndSubProps)
40
- if (!batchMode && minimize !== false) minimizeClaims(entity.claims)
41
+ if (!batchMode && minimize !== false) {
42
+ minimizeClaims(entity.claims)
43
+ minimizeSitelinks(entity.sitelinks)
44
+ }
41
45
  return entity
42
46
  }
47
+
48
+ const minimizeSitelinks = sitelinks => {
49
+ if (!sitelinks) return
50
+ for (const [ site, siteObj ] of Object.entries(sitelinks)) {
51
+ if (siteObj.badges.length === 0) {
52
+ sitelinks[site] = siteObj.title
53
+ }
54
+ }
55
+ }
@@ -9,7 +9,8 @@ const propsMap = {
9
9
  hashes: 'keepHashes',
10
10
  nontruthy: 'keepNonTruthy',
11
11
  nondeprecated: 'keepNonDeprecated',
12
- ranks: 'keepRanks'
12
+ ranks: 'keepRanks',
13
+ badges: 'keepBadges',
13
14
  }
14
15
 
15
16
  module.exports = ({ simplify: simplifyOption, keep: props, timeConverter }) => {
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ alias: 'rd',
3
+ args: '<entity> <language>',
4
+ description: 'remove a description on an entity for a given language',
5
+ options: require('../lib/common_options').editCommands,
6
+ examples: [
7
+ { args: 'Q4115189 it', comment: 'Remove Q4115189 description in Italian' },
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ alias: 'rl',
3
+ args: '<entity> <language>',
4
+ description: 'remove a label on an entity for a given language',
5
+ options: require('../lib/common_options').editCommands,
6
+ examples: [
7
+ { args: 'Q4115189 it', comment: 'Remove Q4115189 label in Italian' },
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ alias: 'rs',
3
+ args: '<entity> <site>',
4
+ description: 'remove a sitelink on an entity for a given site',
5
+ options: require('../lib/common_options').editCommands,
6
+ examples: [
7
+ { args: 'Q4115189 enwikiquote', comment: 'Remove the link from Q4115189 to any article in the English Wikiquote' },
8
+ ]
9
+ }
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ alias: 'ss',
3
+ args: '<entity> <site> <title> [badges]',
4
+ description: 'set a sitelink on an entity for a given site',
5
+ options: require('../lib/common_options').editCommands,
6
+ examples: [
7
+ { args: 'Q4115189 enwikiquote "The Sandbox"', comment: "Link Q4115189 to the article 'The Sandbox' on the English Wikiquote" },
8
+ { args: 'Q4115189 enwikiquote "The Sandbox" Q17437796,Q17437798', comment: 'Also set badges for that sitelink' },
9
+ ]
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikibase-cli",
3
- "version": "16.1.2",
3
+ "version": "16.2.0",
4
4
  "description": "A command-line interface to Wikibase",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -50,8 +50,8 @@
50
50
  "shell-quote": "^1.7.3",
51
51
  "split": "^1.0.1",
52
52
  "through": "^2.3.8",
53
- "wikibase-edit": "^5.0.3",
54
- "wikibase-sdk": "^8.0.0",
53
+ "wikibase-edit": "^5.2.0",
54
+ "wikibase-sdk": "^8.1.0",
55
55
  "wikidata-lang": "^2.0.11"
56
56
  },
57
57
  "devDependencies": {