zotero-plugin 1.1.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +12 -2
  2. package/bin/start.py +18 -5
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@ it will issue a new release. When it is ran on a branch named
10
10
  in your repo.
11
11
 
12
12
  For this to work you must have a variable named `GITHUB_TOKEN` in
13
- your travis environment with a githun token with `repo` rights. You
13
+ your travis environment with a github token with `repo` rights. You
14
14
  are allowed one bot account by github; I use this to do the
15
15
  announcements, but you can use one from your own account if you
16
16
  want.
@@ -42,11 +42,17 @@ name = <your test profile name>
42
42
  path = <your test profile absolute path>
43
43
 
44
44
  [zotero]
45
+ path = <explicit path to zotero binary> # optional
45
46
  log = <file name to write log output to> # optional
46
47
  db = <path to zotero.sqlite you want to populate the profile with> # optional
47
48
 
49
+ [plugin]
50
+ source = <plugin source directory> # optional
51
+ build = <command to build your plugin, or false if no build is needed> # optional
52
+
48
53
  [preferences]
49
- extensions.zotero.<your extension>.<some setting> = true
54
+ extensions.zotero.<your extension>.<some setting> = <value>
55
+ extensions.zotero.<your extension>.<some other setting> = <value>
50
56
  ```
51
57
 
52
58
  and add this script to your package.json:
@@ -56,3 +62,7 @@ and add this script to your package.json:
56
62
  ```
57
63
 
58
64
  then when you execute `npm start`, zotero will start up with the latest build of your plugin installed.
65
+
66
+ **DO CREATE A BACKUP OF YOUR ZOTERO DATA *AND* YOUR ZOTERO PROFILE BEFORE USING THIS THE FIRST TIME**
67
+
68
+ `zotero-start` will **blindly** trust you've set it up right and will **alter data** in the profile
package/bin/start.py CHANGED
@@ -4,7 +4,7 @@ import os, sys
4
4
  import shutil
5
5
  import json
6
6
  import configparser
7
- import argparse
7
+ import glob
8
8
  import shlex
9
9
  import xml.etree.ElementTree as ET
10
10
  import subprocess
@@ -28,7 +28,7 @@ class Config:
28
28
  self.zotero = types.SimpleNamespace(
29
29
  path=config.get('zotero', 'path', fallback=None),
30
30
  log=config.get('zotero', 'log', fallback=None),
31
- db=config.get('profile', 'db', fallback=None)
31
+ db=config.get('zotero', 'db', fallback=None)
32
32
  )
33
33
 
34
34
  if self.zotero.path:
@@ -43,6 +43,11 @@ class Config:
43
43
  if self.zotero.log:
44
44
  self.zotero.log = os.path.expanduser(self.zotero.log)
45
45
 
46
+ self.plugin = types.SimpleNamespace(
47
+ source=os.path.abspath(config.get('plugin', 'source', fallback=self.find_source())),
48
+ build=config.get('plugin', 'build', fallback='npm run build')
49
+ )
50
+
46
51
  if 'preferences' in config:
47
52
  self.preference = { k: self.pref_value(v) for k, v in dict(config['preferences']).items() }
48
53
  else:
@@ -57,6 +62,13 @@ class Config:
57
62
  self.preference['extensions.lastAppBuildId'] = None
58
63
  self.preference['extensions.lastAppVersion'] = None
59
64
 
65
+ def find_source(self):
66
+ for rdf in glob.glob(os.path.join('*', 'install.rdf')):
67
+ return os.path.dirname(rdf)
68
+ if os.path.isdir('build'):
69
+ return 'build'
70
+ return False
71
+
60
72
  def pref_value(self, v):
61
73
  if v in ['true', 'false']: return v == 'true'
62
74
  if v == 'null': return None
@@ -114,15 +126,16 @@ def system(cmd):
114
126
  print('$', cmd)
115
127
  subprocess.run(cmd, shell=True, check=True)
116
128
 
117
- system('npm run build')
129
+ if config.plugin.build:
130
+ system(config.plugin.build)
118
131
 
119
132
  if config.zotero.db:
120
133
  shutil.copyfile(config.zotero.db, os.path.join(config.profile.path, 'zotero', 'zotero.sqlite'))
121
134
 
122
- for plugin_id in ET.parse(os.path.join('build', 'install.rdf')).getroot().findall('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/{http://www.mozilla.org/2004/em-rdf#}id'):
135
+ for plugin_id in ET.parse(os.path.join(config.plugin.source, 'install.rdf')).getroot().findall('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/{http://www.mozilla.org/2004/em-rdf#}id'):
123
136
  plugin_path = os.path.join(config.profile.path, 'extensions', plugin_id.text)
124
137
  with open(plugin_path, 'w') as f:
125
- sources = os.path.join(os.getcwd(), 'build')
138
+ sources = config.plugin.source
126
139
  if sources[-1] != '/': sources += '/'
127
140
  print(sources, file=f)
128
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
4
4
  "description": "Zotero plugin builder",
5
5
  "homepage": "https://github.com/retorquere/zotero-plugin/wiki",
6
6
  "bin": {
@@ -40,7 +40,7 @@
40
40
  "current-git-branch": "^1.1.0",
41
41
  "dotenv": "^16.0.0",
42
42
  "ejs": "^3.1.6",
43
- "eslint": "^8.8.0",
43
+ "eslint": "^8.9.0",
44
44
  "eslint-plugin-import": "^2.25.4",
45
45
  "eslint-plugin-prefer-arrow": "^1.2.3",
46
46
  "glob": "^7.2.0",